feat(appstate): emit setting events (#2057)
This commit is contained in:
@@ -96,6 +96,24 @@ export type BaileysEventMap = {
|
|||||||
'newsletter.view': { id: string; server_id: string; count: number }
|
'newsletter.view': { id: string; server_id: string; count: number }
|
||||||
'newsletter-participants.update': { id: string; author: string; user: string; new_role: string; action: string }
|
'newsletter-participants.update': { id: string; author: string; user: string; new_role: string; action: string }
|
||||||
'newsletter-settings.update': { id: string; update: any }
|
'newsletter-settings.update': { id: string; update: any }
|
||||||
|
|
||||||
|
/** Settings and actions sync events */
|
||||||
|
'chats.lock': { id: string; locked: boolean }
|
||||||
|
'settings.update':
|
||||||
|
| { setting: 'unarchiveChats'; value: boolean }
|
||||||
|
| { setting: 'locale'; value: string }
|
||||||
|
| { setting: 'disableLinkPreviews'; value: proto.SyncActionValue.IPrivacySettingDisableLinkPreviewsAction }
|
||||||
|
| { setting: 'timeFormat'; value: proto.SyncActionValue.ITimeFormatAction }
|
||||||
|
| { setting: 'privacySettingRelayAllCalls'; value: proto.SyncActionValue.IPrivacySettingRelayAllCalls }
|
||||||
|
| { setting: 'statusPrivacy'; value: proto.SyncActionValue.IStatusPrivacyAction }
|
||||||
|
| {
|
||||||
|
setting: 'notificationActivitySetting'
|
||||||
|
value: proto.SyncActionValue.NotificationActivitySettingAction.NotificationActivitySetting
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
setting: 'channelsPersonalisedRecommendation'
|
||||||
|
value: proto.SyncActionValue.IPrivacySettingChannelsPersonalisedRecommendationAction
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BufferedEventData = {
|
export type BufferedEventData = {
|
||||||
|
|||||||
@@ -904,6 +904,47 @@ export const processSyncAction = (
|
|||||||
labelId: syncAction.index[1]
|
labelId: syncAction.index[1]
|
||||||
} as MessageLabelAssociation)
|
} as MessageLabelAssociation)
|
||||||
})
|
})
|
||||||
|
} else if (action?.localeSetting?.locale) {
|
||||||
|
ev.emit('settings.update', { setting: 'locale', value: action.localeSetting.locale })
|
||||||
|
} else if (action?.timeFormatAction) {
|
||||||
|
ev.emit('settings.update', { setting: 'timeFormat', value: action.timeFormatAction })
|
||||||
|
} else if (action?.pnForLidChatAction) {
|
||||||
|
if (action.pnForLidChatAction.pnJid) {
|
||||||
|
ev.emit('lid-mapping.update', { lid: id!, pn: action.pnForLidChatAction.pnJid })
|
||||||
|
}
|
||||||
|
} else if (action?.privacySettingRelayAllCalls) {
|
||||||
|
ev.emit('settings.update', {
|
||||||
|
setting: 'privacySettingRelayAllCalls',
|
||||||
|
value: action.privacySettingRelayAllCalls
|
||||||
|
})
|
||||||
|
} else if (action?.statusPrivacy) {
|
||||||
|
ev.emit('settings.update', { setting: 'statusPrivacy', value: action.statusPrivacy })
|
||||||
|
} else if (action?.lockChatAction) {
|
||||||
|
ev.emit('chats.lock', { id: id!, locked: !!action.lockChatAction.locked })
|
||||||
|
} else if (action?.privacySettingDisableLinkPreviewsAction) {
|
||||||
|
ev.emit('settings.update', {
|
||||||
|
setting: 'disableLinkPreviews',
|
||||||
|
value: action.privacySettingDisableLinkPreviewsAction
|
||||||
|
})
|
||||||
|
} else if (action?.notificationActivitySettingAction?.notificationActivitySetting) {
|
||||||
|
ev.emit('settings.update', {
|
||||||
|
setting: 'notificationActivitySetting',
|
||||||
|
value: action.notificationActivitySettingAction.notificationActivitySetting
|
||||||
|
})
|
||||||
|
} else if (action?.lidContactAction) {
|
||||||
|
ev.emit('contacts.upsert', [
|
||||||
|
{
|
||||||
|
id: id!,
|
||||||
|
name: action.lidContactAction.fullName!,
|
||||||
|
lid: id!,
|
||||||
|
phoneNumber: undefined
|
||||||
|
}
|
||||||
|
])
|
||||||
|
} else if (action?.privacySettingChannelsPersonalisedRecommendationAction) {
|
||||||
|
ev.emit('settings.update', {
|
||||||
|
setting: 'channelsPersonalisedRecommendation',
|
||||||
|
value: action.privacySettingChannelsPersonalisedRecommendationAction
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
logger?.debug({ syncAction, id }, 'unprocessable update')
|
logger?.debug({ syncAction, id }, 'unprocessable update')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user