Amarula.Protocol.Messages.Poll (amarula v0.1.0)
View SourcePoll vote tally, ported from Baileys getAggregateVotesInPollMessage
(src/Utils/messages.ts).
A vote's selectedOptions are SHA-256 hashes of the chosen option names, so
tallying maps each poll option's sha256(option_name) back to its name and
collects the voters whose decrypted votes contain that hash.
Decrypt incoming votes with Amarula.Protocol.Messages.PollCrypto.decrypt_vote/2
first; pass the results here as {voter_jid, %PollVoteMessage{}} tuples.
Summary
Functions
Tally votes against a poll-creation message. votes is a list of
{voter_jid, %Proto.Message.PollVoteMessage{}} (decrypted). Returns a list of
%{name: option_name, voters: [voter_jid]}, one per poll option (plus an
"Unknown" bucket for hashes not matching any option).
Types
Functions
@spec tally(Amarula.Protocol.Proto.Message.t(), [{String.t(), struct()}]) :: [ tally_entry() ]
Tally votes against a poll-creation message. votes is a list of
{voter_jid, %Proto.Message.PollVoteMessage{}} (decrypted). Returns a list of
%{name: option_name, voters: [voter_jid]}, one per poll option (plus an
"Unknown" bucket for hashes not matching any option).