Send compat-msgid to compat clients (BF old android client)

This commit is contained in:
2023-06-18 01:55:58 +02:00
parent 67218d8045
commit aefc368cfd
10 changed files with 65 additions and 29 deletions

View File

@@ -9,7 +9,6 @@ import (
"blackforestbytes.com/simplecloudnotifier/logic"
"blackforestbytes.com/simplecloudnotifier/models"
"database/sql"
"fmt"
"github.com/gin-gonic/gin"
"gogs.mikescher.com/BlackForestBytes/goext/dataext"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
@@ -524,7 +523,7 @@ func (h CompatHandler) Requery(g *gin.Context) ginresp.HTTPResponse {
}
compMsgs = append(compMsgs, models.CompatMessage{
Title: compatizeMessageTitle(ctx, h.app, v),
Title: h.app.CompatizeMessageTitle(ctx, v),
Body: v.Content,
Priority: v.Priority,
Timestamp: v.Timestamp().Unix(),
@@ -772,7 +771,7 @@ func (h CompatHandler) Expand(g *gin.Context) ginresp.HTTPResponse {
Success: true,
Message: "ok",
Data: models.CompatMessage{
Title: compatizeMessageTitle(ctx, h.app, msg),
Title: h.app.CompatizeMessageTitle(ctx, msg),
Body: msg.Content,
Trimmed: langext.Ptr(false),
Priority: msg.Priority,
@@ -919,16 +918,3 @@ func (h CompatHandler) Upgrade(g *gin.Context) ginresp.HTTPResponse {
IsPro: user.IsPro,
}))
}
func compatizeMessageTitle(ctx *logic.AppContext, app *logic.Application, msg models.Message) string {
if msg.ChannelInternalName == "main" {
return msg.Title
}
channel, err := app.Database.Primary.GetChannelByID(ctx, msg.ChannelID)
if err != nil {
return fmt.Sprintf("[%s] %s", "%SCN-ERR%", msg.Title)
}
return fmt.Sprintf("[%s] %s", channel.DisplayName, msg.Title)
}