commit af00067363d2162f63fc6d75cc8ebbac90b98099
parent 208e0e735481897b4d9845e8a81e30737f20f8aa
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 29 Dec 2023 21:19:16 -0500
cleanup
Diffstat:
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/pkg/web/handlers/interceptors/slashInterceptor.go b/pkg/web/handlers/interceptors/slashInterceptor.go
@@ -537,22 +537,22 @@ func handleDiceCmd(c *command.Command) (handled bool) {
func handleRandCmd(c *command.Command) (handled bool) {
if strings.HasPrefix(c.Message, "/rand") {
- min := 1
- max := 6
+ minV := 1
+ maxV := 6
var dice int
if m := randRgx.FindStringSubmatch(c.Message); len(m) == 3 {
var err error
- min, err = strconv.Atoi(m[1])
+ minV, err = strconv.Atoi(m[1])
if err != nil {
c.Err = err
return true
}
- max, err = strconv.Atoi(m[2])
+ maxV, err = strconv.Atoi(m[2])
if err != nil {
c.Err = err
return true
}
- if max <= min {
+ if maxV <= minV {
c.Err = errors.New("max must be greater than min")
return true
}
@@ -560,7 +560,7 @@ func handleRandCmd(c *command.Command) (handled bool) {
c.Err = errors.New("invalid /rand command")
return true
}
- dice = utils.RandInt(min, max)
+ dice = utils.RandInt(minV, maxV)
raw := fmt.Sprintf(`rolling dice for @%s ... "%d"`, c.AuthUser.Username, dice)
msg := fmt.Sprintf(`rolling dice for @%s ... "<span style="color: white;">%d</span>"`, c.AuthUser.Username, dice)
msg, _ = dutils.ColorifyTaggedUsers(msg, c.DB.GetUsersByUsername)
@@ -1001,7 +1001,7 @@ func handlePMCmd(c *command.Command) (handled bool) {
if newMsg == "/d" || strings.HasPrefix(newMsg, "/d ") {
handled = handleDeleteMsgCmd(c)
- if c.Err != nil && c.Err != command.ErrRedirect {
+ if c.Err != nil && !errors.Is(c.Err, command.ErrRedirect) {
return handled
}
c.Err = command.ErrRedirect
@@ -1289,22 +1289,22 @@ func handleInboxCmd(c *command.Command) (handled bool) {
return true
}
- html := message
+ inboxHTML := message
if tryEncrypt {
if toUser.GPGPublicKey == "" {
c.Err = errors.New("user has no pgp public key")
return true
}
- html, err = utils.GeneratePgpEncryptedMessage(toUser.GPGPublicKey, message)
+ inboxHTML, err = utils.GeneratePgpEncryptedMessage(toUser.GPGPublicKey, message)
if err != nil {
c.Err = errors.New("failed to encrypt")
return true
}
- html = strings.Join(strings.Split(html, "\n"), " ")
+ inboxHTML = strings.Join(strings.Split(inboxHTML, "\n"), " ")
}
- html, _, _ = dutils.ProcessRawMessage(c.DB, html, c.RoomKey, c.AuthUser.ID, c.Room.ID, nil, c.AuthUser.CanUseMultiline, c.AuthUser.ManualMultiline)
- c.DB.CreateInboxMessage(html, c.Room.ID, c.AuthUser.ID, toUser.ID, true, false, nil)
+ inboxHTML, _, _ = dutils.ProcessRawMessage(c.DB, inboxHTML, c.RoomKey, c.AuthUser.ID, c.Room.ID, nil, c.AuthUser.CanUseMultiline, c.AuthUser.ManualMultiline)
+ c.DB.CreateInboxMessage(inboxHTML, c.Room.ID, c.AuthUser.ID, toUser.ID, true, false, nil)
c.DataMessage = "/inbox " + string(username) + " "
c.Err = command.NewErrSuccess("inbox sent")