feat: add db
This commit is contained in:
@@ -61,7 +61,7 @@ async function handleRequest(request: BridgeRequest) {
|
||||
}
|
||||
|
||||
case "listContacts": {
|
||||
const contacts = await WPP.contact.getAllContacts();
|
||||
const contacts = await WPP.contact.list();
|
||||
|
||||
const result = request.params?.limit
|
||||
? contacts.slice(0, request.params.limit)
|
||||
@@ -240,7 +240,7 @@ function start() {
|
||||
/*
|
||||
* Forward new-message events to Node.
|
||||
*/
|
||||
WPP.chat.on("chat.new_message", (message: unknown) => {
|
||||
WPP.on("chat.new_message", (message: unknown) => {
|
||||
if (socket?.readyState !== WebSocket.OPEN) {
|
||||
return;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ function start() {
|
||||
send({
|
||||
type: "event",
|
||||
event: "message",
|
||||
data: serialize(message),
|
||||
data: serializeMessage(message),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -163,6 +163,7 @@ export function serializeContact(contact: any): ContactDTO {
|
||||
pushname: contact.pushname ?? null,
|
||||
shortName: contact.shortName ?? null,
|
||||
formattedName: contact.formattedName ?? null,
|
||||
notifyName: contact.notifyName ?? null,
|
||||
number: contact.number ?? null,
|
||||
|
||||
isMe: contact.isMe ?? false,
|
||||
@@ -279,6 +280,7 @@ export function serializeMessage(message: any): MessageDTO {
|
||||
forwardingScore: message.forwardingScore ?? 0,
|
||||
isStarred: message.isStarred ?? false,
|
||||
broadcast: message.broadcast ?? false,
|
||||
notifyName: message.notifyName ?? null,
|
||||
mentionedIds: Array.isArray(message.mentionedIds)
|
||||
? message.mentionedIds.map(serializeId)
|
||||
: [],
|
||||
|
||||
Vendored
+3
-1
@@ -52,11 +52,13 @@ declare const WPP: {
|
||||
};
|
||||
|
||||
contact: {
|
||||
getAllContacts(): Promise<any[]>;
|
||||
list(): Promise<any[]>;
|
||||
get(contactId: string): any | undefined;
|
||||
};
|
||||
|
||||
group: {
|
||||
getAllGroups(): Promise<any[]>;
|
||||
};
|
||||
|
||||
on(event: string, callback: (...args: any[]) => void): void;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user