Skip to content

Commit 9fe059e

Browse files
[MM-56069] Add check for emoji limit (#676)
* [MM-56069] Add check for emoji limit * Update loadtest/control/gencontroller/actions.go Co-authored-by: Alejandro García Montoro <[email protected]> * Update loadtest/control/simulcontroller/actions.go Co-authored-by: Alejandro García Montoro <[email protected]> --------- Co-authored-by: Alejandro García Montoro <[email protected]>
1 parent 8bc4f81 commit 9fe059e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

loadtest/control/gencontroller/actions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,17 @@ func (c *GenController) addReaction(u user.User) (res control.UserActionResponse
407407
}
408408
}
409409

410+
if reactionLimit := u.Store().Config().ServiceSettings.UniqueEmojiReactionLimitPerPost; reactionLimit != nil {
411+
uniqueEmojiNames := map[string]bool{reaction.EmojiName: true}
412+
for _, r := range reactions {
413+
uniqueEmojiNames[r.EmojiName] = true
414+
}
415+
416+
if len(uniqueEmojiNames) >= *reactionLimit {
417+
return control.UserActionResponse{Info: "reaction limit reached"}
418+
}
419+
}
420+
410421
err = u.SaveReaction(reaction)
411422
if err != nil {
412423
return control.UserActionResponse{Err: control.NewUserError(err)}

loadtest/control/simulcontroller/actions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,17 @@ func (c *SimulController) addReaction(u user.User) control.UserActionResponse {
825825
}
826826
}
827827

828+
if reactionLimit := u.Store().Config().ServiceSettings.UniqueEmojiReactionLimitPerPost; reactionLimit != nil {
829+
uniqueEmojiNames := map[string]bool{reaction.EmojiName: true}
830+
for _, r := range reactions {
831+
uniqueEmojiNames[r.EmojiName] = true
832+
}
833+
834+
if len(uniqueEmojiNames) >= *reactionLimit {
835+
return control.UserActionResponse{Info: "reaction limit reached"}
836+
}
837+
}
838+
828839
if u.SaveReaction(reaction); err != nil {
829840
return control.UserActionResponse{Err: control.NewUserError(err)}
830841
}

0 commit comments

Comments
 (0)