sampaiodiego / rocket.chat.app-poll

Rocket.Chat App for creating polls.
MIT License
50 stars 39 forks source link

Initialize poll with pre-defined reactions #1

Closed sampaiodiego closed 5 years ago

sampaiodiego commented 6 years ago

Send the message with pre-added reactions so people don't need to search for a reaction to vote.

igor9silva commented 5 years ago

Hi @sampaiodiego! Any updates on that subject? I'm willing to help, just point me out what you have until now :)

sampaiodiego commented 5 years ago

thanks @igor9silva

with recent updates on apps engine, I was thinking on changing from using reactions to "action buttons" that triggers slash commands. so create a slash command to receive the vote and update the message.

but I don't know if action buttons support emojis..

igor9silva commented 5 years ago

@sampaiodiego I'm trying the action buttons approach with something like:

builder.addAttachment({
    actions: options.map((opt: string) => ({ type: MessageActionType.BUTTON, text: opt, msg_in_chat_window: true, msg: opt })),
});

It works fine, but I'm having a hard time trying to compute the votes.

I'd like to react to the original message when the user clicks the button, but I don't see anyway to achieve this. As a fallback, I'm trying to re-send the original message adding the vote-count, but I also don't see how to retrieve the original message ID.

Any tips?

sampaiodiego commented 5 years ago

I see. I've been thinking on many alternatives to this limitation.. let me try describe one :smile:

we can change the app to make use of Persistence API to store a generated ID of the poll, store the message ID it was sent, the options and vote counters. This way you can add the poll ID into the action button value, so you'll know what message to update.

this is also a step further if we plan to provide better "reports" of a poll.. so instead of getting the message data and parsing its reactions to generate the report, all poll's data will be securely stored and ready to be consumed.

this is a big change on the app structure, please let me know if want to give it a try, otherwise I can step in and start implementing this.. thanks

igor9silva commented 5 years ago

@sampaiodiego Thanks! I wasn't aware of that API - it made things much easier :)

I've made a PR with those changes (#9), please let me know if I should change anything.