Skip to content

Commit

Permalink
✨ feat: listen to label events onLabel #2689
Browse files Browse the repository at this point in the history
  • Loading branch information
smashah committed May 30, 2022
1 parent 3c836ea commit c25a07e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
14 changes: 13 additions & 1 deletion src/api/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import { isAuthenticated, QRManager, waitForRipeSession } from '../controllers/a
import { ChatId, GroupChatId, Content, Base64, MessageId, ContactId, DataURL, FilePath } from './model/aliases';
import { bleachMessage, decryptMedia } from '@open-wa/wa-decrypt';
import * as path from 'path';
import { CustomProduct, Label, Order, Product } from './model/product';
import { CustomProduct, Order, Product } from './model/product';
import { Label } from './model/label';
import { defaultProcessOptions, Mp4StickerConversionProcessOptions, StickerMetadata } from './model/media';
import { getAndInjectLicense, getAndInjectLivePatch, getLicense } from "../controllers/patch_manager";
import { SimpleListener } from './model/events';
Expand Down Expand Up @@ -868,6 +869,17 @@ export class Client {
public async onIncomingCall(fn: (call: Call) => void) : Promise<Listener | boolean> {
return this.registerListener(SimpleListener.IncomingCall, fn);
}

/**
* Listens to label change events
*
* @event
* @param fn callback
* @fires [[Label]]
*/
public async onLabel(fn: (label: Label) => void) : Promise<Listener | boolean> {
return this.registerListener(SimpleListener.Label, fn);
}

/**
*[REQUIRES AN INSIDERS LICENSE-KEY](https://gum.co/open-wa?tier=Insiders%20Program)
Expand Down
4 changes: 4 additions & 0 deletions src/api/model/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
* Represents [[onButton]]
*/
Button = 'onButton',
/**
* Represents [[onLabel]]
*/
Label = 'onLabel',
/**
* Requires licence
* Represents [[onStory]]
Expand Down
3 changes: 2 additions & 1 deletion src/api/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ export type EasyApiResponse = {

export * from './config'
export * from './media'
export * from './aliases'
export * from './aliases'
export * from './label'
25 changes: 25 additions & 0 deletions src/api/model/label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ContactId, ChatId, MessageId } from "./aliases";

export interface Label {
/**
* The internal ID of the label. Usually a number represented as a string e.g "1"
*/
id: string,
/**
* The text contents of the label
*/
name: string,
/**
* The items that are tagged with this label
*/
items: {
/**
* Labels can be applied to chats, contacts or individual messages. This represents the type of object the label is attached to.
*/
type: "Chat" | "Contact" | "Message",
/**
* The ID of the object that the label is atteched to.
*/
id: ContactId | ChatId | MessageId
}[]
}
25 changes: 0 additions & 25 deletions src/api/model/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,28 +145,3 @@ export interface Order {
*/
message ?: Message
}


export interface Label {
/**
* The internal ID of the label. Usually a number represented as a string e.g "1"
*/
id: string,
/**
* The text contents of the label
*/
name: string,
/**
* The items that are tagged with this label
*/
items: {
/**
* Labels can be applied to chats, contacts or individual messages. This represents the type of object the label is attached to.
*/
type: "Chat" | "Contact" | "Message",
/**
* The ID of the object that the label is atteched to.
*/
id: ContactId | ChatId | MessageId
}[]
}

0 comments on commit c25a07e

Please sign in to comment.