[#329] Resolve "add BROADCAST command and shortcut"
context
as an admin, broadcasting a message to a large signalboost channel can be nerve wracking and certainly something you don't want to do accidentally.
the main feature change introduced in this MR is adding a BROADCAST
command and !
shortcut in order to add some friction to the broadcasting experience. then, after noticing some issues with the way broadcast was operating in dispatcher#messenger, I started pulling some of the broadcast logic into dispatcher#execute.
noticeably, the "default" behavior - a non-command-prefixed message - now is only one of two scenarios:
- accidental send by an admin
Did you mean to prefix your message with BROADCAST? Send HELP to see a list of all commands.
- hotline message by a subscriber/rando
- if hotline is on, forwards message (with attachments!) to admins of the channel
Your message was forwarded to the admins of [foobar]. Send HELP to list valid commands. Send HELLO to subscribe.
- if hotline if off, responds with an error message:
'Sorry, this channel does not have a hotline enabled. Send HELP to list valid commands.'
changes
parse
the parse step is now only responsible for parsing commands and generating a parse-related error. dealing with a NONE
command is pushed up to dispatcher#execute, which allows those errors to be treated in the language of the membership!
creates parseErrorTypes: MISSING_COMMAND | INVALID_PAYLOAD
new command:
commands.NONE
removes NOOP
as a command/status.
execute
much of the work here expands on the notification
pattern, now with an optional argument for attachments. doing so:
- pulls logic checking if someone is an admin/subscriber out of messenger and parse layers
- allows all notifications/message headers to be generated in the correct language of the channel member
- fixes attachments for hotline messages
🖼
now using notifications:
-
✨ BROADCAST
-
✨ hotline messages
messenger
using notifications for broadcasts and hotline messages significantly simplifies the messenger layer! #outthedoor
-
parseMessageType
checks ifHOTLINE_MESSAGE
|BROADCAST_MESSAGE
|COMMAND
-
broadcast
sends notifications -
handleHotlineMessage
responds to sender and sends notifications
notes
- I have not sufficiently done translations (it always ends up being an outsize amount of work to go back and forth on them) so just wanna check you're cool on the English copy before i do so!
- i have not (yet) refactored
sdMessageOf
to include attachments, and am instead passing them through functions. i realize this is not quite ideal!
Closes #329 (closed)