Send channel as prefix for compat clients
This commit is contained in:
@@ -694,3 +694,41 @@ func TestCompatRequery(t *testing.T) {
|
||||
tt.AssertEqual(t, "count", 0, rq7.Count)
|
||||
|
||||
}
|
||||
|
||||
func TestCompatTitlePatch(t *testing.T) {
|
||||
ws, baseUrl, stop := tt.StartSimpleWebserver(t)
|
||||
defer stop()
|
||||
|
||||
pusher := ws.Pusher.(*push.TestSink)
|
||||
|
||||
r0 := tt.RequestPost[gin.H](t, baseUrl, "/api/v2/users", gin.H{
|
||||
"agent_model": "DUMMY_PHONE",
|
||||
"agent_version": "4X",
|
||||
"client_type": "ANDROID",
|
||||
"fcm_token": "DUMMY_FCM",
|
||||
})
|
||||
|
||||
uid := r0["user_id"].(string)
|
||||
admintok := r0["admin_key"].(string)
|
||||
sendtok := r0["send_key"].(string)
|
||||
|
||||
type clientlist struct {
|
||||
Clients []gin.H `json:"clients"`
|
||||
}
|
||||
|
||||
clist1 := tt.RequestAuthGet[clientlist](t, admintok, baseUrl, fmt.Sprintf("/api/v2/users/%s/clients", url.QueryEscape(uid)))
|
||||
|
||||
tt.SetCompatClient(t, ws, clist1.Clients[0]["client_id"].(string))
|
||||
|
||||
_ = tt.RequestPost[gin.H](t, baseUrl, "/", gin.H{
|
||||
"key": sendtok,
|
||||
"user_id": uid,
|
||||
"title": "HelloWorld_001",
|
||||
"channel": "TestChan",
|
||||
})
|
||||
|
||||
tt.AssertEqual(t, "messageCount", 1, len(pusher.Data))
|
||||
tt.AssertStrRepEqual(t, "msg.title", "HelloWorld_001", pusher.Last().Message.Title)
|
||||
tt.AssertStrRepEqual(t, "msg.ovrTitle", "[TestChan] HelloWorld_001", pusher.Last().CompatTitleOverride)
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package util
|
||||
|
||||
import (
|
||||
"blackforestbytes.com/simplecloudnotifier/logic"
|
||||
"gogs.mikescher.com/BlackForestBytes/goext/sq"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -64,3 +65,14 @@ func CreateCompatID(t *testing.T, ws *logic.Application, idtype string, newid st
|
||||
|
||||
return uidold
|
||||
}
|
||||
|
||||
func SetCompatClient(t *testing.T, ws *logic.Application, cid string) {
|
||||
ctx := ws.NewSimpleTransactionContext(5 * time.Second)
|
||||
defer ctx.Cancel()
|
||||
|
||||
_, err := ws.Database.Primary.DB().Exec(ctx, "INSERT INTO compat_clients (client_id) VALUES (:cid)", sq.PP{"cid": cid})
|
||||
TestFailIfErr(t, err)
|
||||
|
||||
err = ctx.CommitTransaction()
|
||||
TestFailIfErr(t, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user