feat: Event messages (#3345)
* feat: add createCallLink function * feat: create Event class * feat: add functionality for sending Events * feat: add editEvent function * refactor: send event location prop as wa does * refactor: combine modules * feat: add sendResponseToEvent function * fix: createEventCallLink parameter * docs: add documentation * fix: eslint * refactor: change timestamp to Date for the user's convenience * refactor: rename 'Event' to 'ScheduledEvent' for more clarity * style: fix typo in inner function * refactor: remove unnecessary inner function * refactor: rename 'sendResponseToEvent' to 'sendResponseToScheduledEvent' for more clarity * fix: update the module name
This commit is contained in:
parent
ab321f3d7e
commit
f9db14d185
3 changed files with 261 additions and 4 deletions
|
|
@ -111,6 +111,7 @@ exports.MessageTypes = {
|
|||
REACTION: 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
||||
POLL_CREATION: 'poll_creation',
|
||||
SCHEDULED_EVENT_CREATION: 'scheduled_event_creation',
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -114,6 +114,11 @@ exports.ExposeStore = () => {
|
|||
window.Store.ForwardUtils = {
|
||||
...window.require('WAWebChatForwardMessage')
|
||||
};
|
||||
window.Store.ScheduledEventMsgUtils = {
|
||||
...window.require('WAWebGenerateEventCallLink'),
|
||||
...window.require('WAWebSendEventEditMsgAction'),
|
||||
...window.require('WAWebSendEventResponseMsgAction')
|
||||
};
|
||||
window.Store.VCard = {
|
||||
...window.require('WAWebFrontendVcardUtils'),
|
||||
...window.require('WAWebVcardParsingUtils'),
|
||||
|
|
|
|||
|
|
@ -116,6 +116,34 @@ exports.LoadUtils = () => {
|
|||
delete options.poll;
|
||||
}
|
||||
|
||||
let eventOptions = {};
|
||||
if (options.event) {
|
||||
const { name, startTimeTs, eventSendOptions } = options.event;
|
||||
const { messageSecret } = eventSendOptions;
|
||||
eventOptions = {
|
||||
type: 'event_creation',
|
||||
eventName: name,
|
||||
eventDescription: eventSendOptions.description,
|
||||
eventStartTime: startTimeTs,
|
||||
eventEndTime: eventSendOptions.endTimeTs,
|
||||
eventLocation: eventSendOptions.location && {
|
||||
degreesLatitude: 0,
|
||||
degreesLongitude: 0,
|
||||
name: eventSendOptions.location
|
||||
},
|
||||
eventJoinLink: await window.Store.ScheduledEventMsgUtils.createEventCallLink(
|
||||
startTimeTs,
|
||||
eventSendOptions.callType
|
||||
),
|
||||
isEventCanceled: eventSendOptions.isEventCanceled,
|
||||
messageSecret:
|
||||
Array.isArray(messageSecret) && messageSecret.length === 32
|
||||
? new Uint8Array(messageSecret)
|
||||
: window.crypto.getRandomValues(new Uint8Array(32)),
|
||||
};
|
||||
delete options.event;
|
||||
}
|
||||
|
||||
let vcardOptions = {};
|
||||
if (options.contactCard) {
|
||||
let contact = window.Store.Contact.get(options.contactCard);
|
||||
|
|
@ -255,6 +283,7 @@ exports.LoadUtils = () => {
|
|||
...quotedMsgOptions,
|
||||
...locationOptions,
|
||||
..._pollOptions,
|
||||
...eventOptions,
|
||||
...vcardOptions,
|
||||
...buttonOptions,
|
||||
...listOptions,
|
||||
|
|
|
|||
Loading…
Reference in a new issue