diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts index 856d8cb2..5cd2190f 100644 --- a/src/Socket/chats.ts +++ b/src/Socket/chats.ts @@ -858,6 +858,30 @@ export const makeChatsSocket = (config: SocketConfig) => { ) } + /** + * Add or Edit Contact + */ + const addOrEditContact = (jid: string, contact: proto.SyncActionValue.IContactAction) => { + return chatModify( + { + contact + }, + jid + ) + } + + /** + * Remove Contact + */ + const removeContact = (jid: string) => { + return chatModify( + { + contact: null + }, + jid + ) + } + /** * Adds label */ @@ -1087,6 +1111,8 @@ export const makeChatsSocket = (config: SocketConfig) => { resyncAppState, chatModify, cleanDirtyBits, + addOrEditContact, + removeContact, addLabel, addChatLabel, removeChatLabel, diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index c3542dd6..adef5781 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -110,6 +110,7 @@ export type ChatModification = lastMessages: LastMessageList } | { delete: true; lastMessages: LastMessageList } + | { contact: proto.SyncActionValue.IContactAction | null } // Label | { addLabel: LabelActionBody } // Label assosiation diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts index 2a1f0b6b..6cbba12c 100644 --- a/src/Utils/chat-utils.ts +++ b/src/Utils/chat-utils.ts @@ -605,6 +605,16 @@ export const chatModificationToAppPatch = (mod: ChatModification, jid: string) = apiVersion: 5, operation: OP.SET } + } else if ('contact' in mod) { + patch = { + syncAction: { + contactAction: mod.contact || {} + }, + index: ['contact', jid], + type: 'critical_unblock_low', + apiVersion: 2, + operation: mod.contact ? OP.SET : OP.REMOVE + } } else if ('star' in mod) { const key = mod.star.messages[0] patch = {