New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Message.recalled()
#1735
Add Message.recalled()
#1735
Conversation
src/user/common.spec.ts
Outdated
import { SinonSandbox } from 'sinon' | ||
import { Puppet, RoomPayload } from 'wechaty-puppet' | ||
|
||
export const mockRoomPayload = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think coupling between unit tests is a good idea, and also it seems no strong reason for us to seperate this method to create new file.
Please move the code to the unit test file instead of creating this new file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I do this is to make code climate happy, it was complaining about duplicate code in code base. I can revert the last commit if you think that's what you want.
src/user/message.ts
Outdated
@@ -387,6 +387,24 @@ export class Message extends Accessory implements Sayable { | |||
return this.payload.text || '' | |||
} | |||
|
|||
public async recalled (): Promise<Message | null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename recalled()
to toRecalled()
because we have already had the following methods:
toContact()
toFileBox()
toUrlLink()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for PR to support RECALLED
type of messages!
Those codes look good, however, it has some minor issues need to be changed.
Please follow my review and fix them as well, then we will be able to prepare to merge them.
@huan Please let me know if you want me to revert back the change of coupling the unit test or not. I will submit changes after that is confirmed :) |
@windmemory Yes, please follow my reviews from your PR. About the code climate I want to ignore it for the unit tests for a while, and think about it later, maybe config it to ignore all *.spec.ts code files. |
Got it, thanks for the confirmation, will submit changes later. |
Changed code according to review, and also add example code for Please let me know if you think anything else needs to be changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Please fix the latest issue then I'll be able to merge it.
src/user/message.ts
Outdated
if (!originalMessageId) { | ||
throw new Error('Can not find recalled message') | ||
} | ||
const message = this.wechaty.Message.load(originalMessageId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move the above line to inside try {}
block.
Thanks for your great contribution! |
np |
Refer to #1728