Skip to content
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

Merged
merged 6 commits into from Apr 15, 2019
Merged

Add Message.recalled() #1735

merged 6 commits into from Apr 15, 2019

Conversation

windmemory
Copy link
Member

Refer to #1728

import { SinonSandbox } from 'sinon'
import { Puppet, RoomPayload } from 'wechaty-puppet'

export const mockRoomPayload = (
Copy link
Member

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.

Copy link
Member Author

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.

@@ -387,6 +387,24 @@ export class Message extends Accessory implements Sayable {
return this.payload.text || ''
}

public async recalled (): Promise<Message | null> {
Copy link
Member

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:

  1. toContact()
  2. toFileBox()
  3. toUrlLink()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, will do.

Copy link
Member

@huan huan left a 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.

@windmemory
Copy link
Member Author

@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 :)

@huan
Copy link
Member

huan commented Apr 14, 2019

@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.

@windmemory
Copy link
Member Author

Got it, thanks for the confirmation, will submit changes later.

@windmemory
Copy link
Member Author

Changed code according to review, and also add example code for Message.toRecalled()

Please let me know if you think anything else needs to be changed.

Copy link
Member

@huan huan left a 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.

if (!originalMessageId) {
throw new Error('Can not find recalled message')
}
const message = this.wechaty.Message.load(originalMessageId)
Copy link
Member

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.

@huan huan merged commit 6ed8349 into wechaty:master Apr 15, 2019
@huan
Copy link
Member

huan commented Apr 15, 2019

Thanks for your great contribution!

@windmemory
Copy link
Member Author

np

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants