Skip to content

Commit

Permalink
Merge pull request #1 from padaliyajay/annotated-pdf-hook
Browse files Browse the repository at this point in the history
new hooks
  • Loading branch information
padaliyajay authored Aug 8, 2024
2 parents d00d212 + df9bd65 commit 5a7c42f
Showing 1 changed file with 51 additions and 5 deletions.
56 changes: 51 additions & 5 deletions src/process/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default class WebhooksEvent {
"meeting-screenshare-started",
"meeting-screenshare-stopped",
"meeting-presentation-changed",
"presentation-uploaded",
"presentation-annotated-pdf-ready",
"user-joined",
"user-left",
"user-audio-voice-enabled",
Expand Down Expand Up @@ -59,6 +61,10 @@ export default class WebhooksEvent {
"SetCurrentPresentationEvtMsg",
"RecordingStatusChangedEvtMsg",
],
PRESENTATION_EVENTS: [
"PresentationConversionCompletedEvtMsg",
"NewPresFileAvailableEvtMsg",
],
USER_EVENTS: [
"UserJoinedMeetingEvtMsg",
"UserLeftMeetingEvtMsg",
Expand Down Expand Up @@ -120,6 +126,8 @@ export default class WebhooksEvent {
if (this.inputEvent) {
if (this.mappedEvent(this.inputEvent, WebhooksEvent.RAW.MEETING_EVENTS)) {
this.meetingTemplate(this.inputEvent);
} else if (this.mappedEvent(this.inputEvent, WebhooksEvent.RAW.PRESENTATION_EVENTS)) {
this.presentationTemplate(this.inputEvent);
} else if (this.mappedEvent(this.inputEvent, WebhooksEvent.RAW.USER_EVENTS)) {
this.userTemplate(this.inputEvent);
} else if (this.mappedEvent(this.inputEvent, WebhooksEvent.RAW.CHAT_EVENTS)) {
Expand Down Expand Up @@ -157,6 +165,10 @@ export default class WebhooksEvent {
return true;
}

if (messageObj?.core?.header?.name === event) {
return true;
}

if (messageObj?.envelope?.name === event) {
return true;
}
Expand Down Expand Up @@ -365,6 +377,40 @@ export default class WebhooksEvent {
};
}

presentationTemplate(messageObj) {
const meetingId = messageObj.core.header.meetingId;
const userId = messageObj.core.header.userId;
const extId = UserMapping.get().getExternalUserID(userId) || "";
const data = messageObj.core.body;

this.outputEvent = {
data: {
"type": "event",
"id": this.mapInternalMessage(messageObj),
"attributes": {
"meeting": {
"internal-meeting-id": meetingId,
"external-meeting-id": IDMapping.get().getExternalMeetingID(meetingId)
},
"user":{
"internal-user-id": userId,
"external-user-id": extId,
}
},
"event": {
"ts": Date.now()
}
}
};

if (this.outputEvent.data.id === "presentation-uploaded") {
this.outputEvent.data.attributes["pres-id"] = data.presentation.id;
this.outputEvent.data.attributes["name"] = data.presentation.name;
} else if (this.outputEvent.data.id === "presentation-annotated-pdf-ready") {
this.outputEvent.data.attributes["pres-id"] = data.presId;
this.outputEvent.data.attributes["annotated-file-uri"] = data.annotatedFileURI;
}
}
rapTemplate(messageObj) {
const data = messageObj.core.body;
this.outputEvent = {
Expand Down Expand Up @@ -524,9 +570,7 @@ export default class WebhooksEvent {
}

mapInternalMessage(message) {
const name = message?.envelope?.name || message?.header?.name;

const mappedMsg = (() => { switch (name) {
const mappedMsg = (name) => { switch (name) {
case "MeetingCreatedEvtMsg": return "meeting-created";
case "MeetingDestroyedEvtMsg": return "meeting-ended";
case "RecordingStatusChangedEvtMsg": return this.handleRecordingStatusChanged(message);
Expand All @@ -552,6 +596,8 @@ export default class WebhooksEvent {
case "PadContentEvtMsg": return "pad-content";
case "PollStartedEvtMsg": return "poll-started";
case "UserRespondedToPollRespMsg": return "poll-responded";
case "PresentationConversionCompletedEvtMsg": return "presentation-uploaded";
case "NewPresFileAvailableEvtMsg": return "presentation-annotated-pdf-ready";
// RAP
case "archive_started": return "rap-archive-started";
case "archive_ended": return "rap-archive-ended";
Expand All @@ -570,8 +616,8 @@ export default class WebhooksEvent {
case "deleted": return "rap-deleted";
case "post_publish_started": return "rap-post-publish-started";
case "post_publish_ended": return "rap-post-publish-ended";
} })();
} };

return mappedMsg;
return mappedMsg(message?.envelope?.name) || mappedMsg(message?.header?.name) || mappedMsg(message?.core?.header?.name);
}
}

0 comments on commit 5a7c42f

Please sign in to comment.