feat: allow only default reactions - #8545
Conversation
4495732 to
b947588
Compare
the UIs are currently advised to only allow the five default reactions in broadcast channels. this PR ensures that from sending site as well as receiving site.
b947588 to
dc6a27e
Compare
| } | ||
|
|
||
| /// Emojis allowed as reactions in broadcast channels. | ||
| const ALLOWED_REACTIONS: [&str; 5] = ["馃憤", "馃憥", "鉂わ笍", "馃槀", "馃檨"]; |
There was a problem hiding this comment.
in the future, this will probably be configurable
| let old_reactions = get_msg_reactions(context, msg_id).await?; | ||
| let old_self_reaction = old_reactions.by_contact.get(&ContactId::SELF); | ||
|
|
||
| if (chat.typ == Chattype::OutBroadcast || chat.typ == Chattype::InBroadcast) |
There was a problem hiding this comment.
| if (chat.typ == Chattype::OutBroadcast || chat.typ == Chattype::InBroadcast) | |
| if matches!(chat.typ, Chattype::OutBroadcast | Chattype::InBroadcast) |
There was a problem hiding this comment.
ftr, i find a simple "if" easier to read, esp if short, but if matches! is the rust way and what we do otherwise, i am fine with that as well
Co-authored-by: Jagoda Estera 艢l膮zak <[email protected]>
Co-authored-by: Jagoda Estera 艢l膮zak <[email protected]>
j-g00da
left a comment
There was a problem hiding this comment.
Implementation-wise looks good (but I missed when it was discussed)
|
UI already now do not allow random reactions in channels by default, but only a subset. to make life for haters or trolls harder, and life of channel owners better :) this is similar to telegram or whatsapp for simplicity in first UI implementations, the subset are the already present default reactions. later we want to have that configurable. this PR just adds an additional layer to enforce the subset - esp as core does not really know what an emoji is, and allows all short strings as reactions |
the UIs are currently advised
to only allow the five default reactions in broadcast channels.
this PR ensures that from sending site as well as receiving site.
soon, we probably want to make the possible reactions configurable, this PR is mainly for some safety until then. once we have an API to change default reactions, we can also easily test "invalid" reactions on the receiving side; currently only sending is tested
successor of #8450