mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-26 11:28:08 +01:00
Initial Poll message receive support
This commit is contained in:
@@ -22,6 +22,9 @@ import type {
|
||||
ProcessedPreview,
|
||||
ProcessedSticker,
|
||||
ProcessedReaction,
|
||||
ProcessedPollCreate,
|
||||
ProcessedPollVote,
|
||||
ProcessedPollTerminate,
|
||||
ProcessedDelete,
|
||||
ProcessedGiftBadge,
|
||||
ProcessedStoryContext,
|
||||
@@ -309,6 +312,53 @@ export function processReaction(
|
||||
};
|
||||
}
|
||||
|
||||
export function processPollCreate(
|
||||
pollCreate?: Proto.DataMessage.IPollCreate | null
|
||||
): ProcessedPollCreate | undefined {
|
||||
if (!pollCreate) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
question: dropNull(pollCreate.question),
|
||||
options: pollCreate.options?.filter(isNotNil) || [],
|
||||
allowMultiple: Boolean(pollCreate.allowMultiple),
|
||||
};
|
||||
}
|
||||
|
||||
export function processPollVote(
|
||||
pollVote?: Proto.DataMessage.IPollVote | null
|
||||
): ProcessedPollVote | undefined {
|
||||
if (!pollVote) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const targetAuthorAci = fromAciUuidBytesOrString(
|
||||
pollVote.targetAuthorAciBinary,
|
||||
undefined,
|
||||
'PollVote.targetAuthorAci'
|
||||
);
|
||||
|
||||
return {
|
||||
targetAuthorAci,
|
||||
targetTimestamp: pollVote.targetSentTimestamp?.toNumber(),
|
||||
optionIndexes: pollVote.optionIndexes?.filter(isNotNil) || [],
|
||||
voteCount: pollVote.voteCount || 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function processPollTerminate(
|
||||
pollTerminate?: Proto.DataMessage.IPollTerminate | null
|
||||
): ProcessedPollTerminate | undefined {
|
||||
if (!pollTerminate) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
targetTimestamp: pollTerminate.targetSentTimestamp?.toNumber(),
|
||||
};
|
||||
}
|
||||
|
||||
export function processDelete(
|
||||
del?: Proto.DataMessage.IDelete | null
|
||||
): ProcessedDelete | undefined {
|
||||
@@ -407,6 +457,9 @@ export function processDataMessage(
|
||||
requiredProtocolVersion: dropNull(message.requiredProtocolVersion),
|
||||
isViewOnce: Boolean(message.isViewOnce),
|
||||
reaction: processReaction(message.reaction),
|
||||
pollCreate: processPollCreate(message.pollCreate),
|
||||
pollVote: processPollVote(message.pollVote),
|
||||
pollTerminate: processPollTerminate(message.pollTerminate),
|
||||
delete: processDelete(message.delete),
|
||||
bodyRanges: filterAndClean(message.bodyRanges),
|
||||
groupCallUpdate: dropNull(message.groupCallUpdate),
|
||||
|
||||
Reference in New Issue
Block a user