dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 5f15bae84f388989939090e045c1a32c56b3ef27
parent 6b4e6968a3a67e818922e8abf2eb425765ce6be6
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 19 Feb 2025 15:00:21 -0800

cleanup

Diffstat:
Mpkg/web/handlers/interceptors/slashInterceptor.go | 21+++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/pkg/web/handlers/interceptors/slashInterceptor.go b/pkg/web/handlers/interceptors/slashInterceptor.go @@ -491,25 +491,26 @@ func handleInviteCmd(c *command.Command) (handled bool) { if m := inviteRgx.FindStringSubmatch(c.Message); len(m) == 3 { username := database.Username(m[1]) nbInvites := utils.Clamp(utils.DoParseInt(m[2]), 1, 10) - tokens := make([]string, 0) - for i := 0; i < nbInvites; i++ { - if inviteToken, err := c.DB.CreateInvitation(c.AuthUser.ID); err == nil { - tokens = append(tokens, fmt.Sprintf(`<span style="color: Aqua; user-select: all; -webkit-user-select: all;">%s</span>`, inviteToken.Token)) - } - } if err := c.SetToUser(username); err != nil { return true } - tokensStr := strings.Join(tokens, "<br />") - c.OrigMessage = "<invitation tokens>" - c.Message = fmt.Sprintf(`invitation tokens:<br />%s`, tokensStr) - c.Raw = true + c.RawMessage(buildInviteMessage(c, nbInvites)) c.RedirectQP.Set(command.RedirectPmQP, string(c.ToUser.Username)) return true } return } +func buildInviteMessage(c *command.Command, nbInvites int) string { + tokens := make([]string, 0) + for i := 0; i < nbInvites; i++ { + if inviteToken, err := c.DB.CreateInvitation(c.AuthUser.ID); err == nil { + tokens = append(tokens, fmt.Sprintf(`<span style="color: Aqua; user-select: all; -webkit-user-select: all;">%s</span>`, inviteToken.Token)) + } + } + return fmt.Sprintf(`invitation tokens:<br />%s`, strings.Join(tokens, "<br />")) +} + func handleHbmCmd(c *command.Command) (handled bool) { if !c.AuthUser.CanSeeHB() { return