revoltchat/backend

bug: server emoji count can be 1 more than the set limit

Closed this issue · 2 comments

What happened?

As pointed out by Toatrika#5321 on Revolt's Server, It seems like servers can have exactly one more emoji than the limit imposed by the server.

I checked the source code and found out that in line 48 of customization/emoji_create.rs, the backend is checking if the server's emoji count is greater than the maximum limit, which means that a server can have 101 emotes.

Proposed change (literally 2 characters that I am too lazy to change)

// ...

- if emojis.len() > config.features.limits.default.server_emoji {
+ if emojis.len() >= config.features.limits.default.server_emoji {
                return Err(create_error!(TooManyEmoji {
                    max: config.features.limits.default.server_emoji,
                }));
            }

// ...

i think in addition to this the default emoji limit should be increased from 100 to 101 to keep consistency (some servers currently have 101 emotes)

I found also this same bug. When Emojis reach to 100 and you delete saved emojis from the list, it doesn't delete older ones and after that I'm able to save more emojis to list, now there is 102 of them. Didn't check how many more this way I could add them.
Something is registering the delete button click, but the value doesn't decrees after that, it's like freeing up one slot and can add more then limit allows.
Revolt_j5XRdZibqj