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

Implement Corp Tag in Wechaty #14

Closed
hcfw007 opened this issue Jul 25, 2022 · 3 comments
Closed

Implement Corp Tag in Wechaty #14

hcfw007 opened this issue Jul 25, 2022 · 3 comments

Comments

@hcfw007
Copy link
Member

hcfw007 commented Jul 25, 2022

In wechaty we already have tags for contact, however some IM (e.g. WeCom) supports tag with groups. We can call that corp tags and implement that in wechaty.

data structure:

export interface CorpTagPayload {
  id: string,
  name: string,
  groupId: string,
}

export interface CorpTagGroupPayload {
  id: string,
  name: string,
}

method signatures:

abstract class CorpTagMixin {
    abstract corpTagContactTagAdd(corpTagGroupId: string, corpTagId: string, contactId: string): Promise<void>
    abstract corpTagContactTagRemove(corpTagGroupId: string, corpTagId: string, contactId: string): Promise<void>
    abstract corpTagGroupAdd(corpTagGroupName: string): Promise<CorpTagGroupPayload | void>
    abstract corpTagGroupDelete(corpTagGroupId: string): Promise<void>
    abstract corpTagTagAdd(corpTagGroupId: string, corpTagName: string): Promise<CorpTagPayload | void>
    abstract corpTagTagDelete(corpTagGroupId: string, corpTagId: string): Promise<void>
    abstract corpTagGroupList(): Promise<CorpTagGroupPayload[]>
    abstract corpTagTagList(corpTagGroupId: string): Promise<CorpTagPayload[]>
    abstract corpTagContactTagList(contactId: string): Promise<CorpTagPayload[]>
}

wechaty methods:

class Contact {
  ...
  addCorpTag (tag: CorpTagPayload | string): void
  removeCorpTag (tag: CorpTagPayload | string): void
  corpTagList () : Promise<CorpTagPayload[]>
  ...
}

class CorpTag {
  listGroups(): Promise<CorpTagGroupPayload[]>
  listTags(tagGroup?: CorpTagGroupPayload | string): Promise<CorpTagPayload[]>
  addGroup(name: string): Promise<CorpTagGroupPayload | viod>
  deleteGroup(corpTagGroup: CorpTagGroupPayload | string): Promise<void>
  addTag(name: string, corpTagGroup: CorpTagGroupPayload | string): Promose<CorpTagPayload | void>
  deleteTag(corpTag: CorpTagPayload | string): Promise<viod>
}
@hcfw007
Copy link
Member Author

hcfw007 commented Jul 26, 2022

After reading dll doc, we should also have

abstract corpTagTagContactList (corpTagGroupId: string, corpTagId: string): Promise<string[]>

@hcfw007
Copy link
Member Author

hcfw007 commented Jul 27, 2022

Update: After reading the dll doc, we redesigned tag module and put tag and corp tag together.
data structure:

enum TagType {
  Personal = 0,
  Corporation = 1,
}

interface TagPayload {
  id: string,
  name: string,
  groupId?: string,
  type: TagType
}

interface TagGroupPayload {
  id: string,
  name: string,
}

export {
  type TagPayload,
  type TagGroupPayload,
  TagType,
}

abstract class

abstract class CorpTagMixin {
    abstract tagContactTagAdd(tagGroupId: string | undefined, tagId: string, contactId: string): Promise<void>
    abstract tagContactTagRemove(tagGroupId: string | undefined, tagId: string, contactId: string): Promise<void>
    abstract tagGroupAdd(tagGroupName: string): Promise<TagGroupPayload | void>
    abstract tagGroupDelete(tagGroupId: string): Promise<void>
    abstract tagTagAdd(tagGroupId: string | undefined, tagName: string): Promise<TagPayload | void>
    abstract tagTagDelete(tagGroupId: string | undefined, tagId: string): Promise<void>
    abstract tagGroupList(): Promise<TagGroupPayload[]>
    abstract tagGroupTagList(tagGroupId: string | undefined): Promise<TagPayload[]>
    abstract tagTagList(): Promise<TagPayload[]>
    abstract tagContactTagList(contactId: string): Promise<TagPayload[]>
    abstract tagTagContactList(tagGroupId: string | undefined, tagId: string): Promise<string[]>
}

This was referenced Jul 27, 2022
@hcfw007
Copy link
Member Author

hcfw007 commented Aug 30, 2022

Merged

@hcfw007 hcfw007 closed this as completed Aug 30, 2022
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

No branches or pull requests

1 participant