Test 1 Can fetch a user's pushers

This commit is contained in:
Dan Peleg 2021-05-05 10:03:01 +03:00
parent c5247d390f
commit 092edee210
8 changed files with 74 additions and 91 deletions

View file

@ -15,6 +15,7 @@
package routing package routing
import ( import (
"encoding/json"
"net/http" "net/http"
"github.com/matrix-org/dendrite/clientapi/httputil" "github.com/matrix-org/dendrite/clientapi/httputil"
@ -27,25 +28,20 @@ import (
// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushers // https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-pushers
type pusherJSON struct { type pusherJSON struct {
PushKey string `json:"pushkey"` PushKey string `json:"pushkey"`
Kind string `json:"kind"` Kind string `json:"kind"`
AppID string `json:"app_id"` AppID string `json:"app_id"`
AppDisplayName string `json:"app_display_name"` AppDisplayName string `json:"app_display_name"`
DeviceDisplayName string `json:"device_display_name"` DeviceDisplayName string `json:"device_display_name"`
ProfileTag string `json:"profile_tag"` ProfileTag string `json:"profile_tag"`
Language string `json:"lang"` Language string `json:"lang"`
Data pusherDataJSON `json:"data"` Data map[string]json.RawMessage `json:"data"`
} }
type pushersJSON struct { type pushersJSON struct {
Pushers []pusherJSON `json:"pushers"` Pushers []pusherJSON `json:"pushers"`
} }
type pusherDataJSON struct {
URL string `json:"url"`
Format string `json:"format"`
}
// GetPushersByLocalpart handles /_matrix/client/r0/pushers // GetPushersByLocalpart handles /_matrix/client/r0/pushers
func GetPushersByLocalpart( func GetPushersByLocalpart(
req *http.Request, userAPI userapi.UserInternalAPI, device *api.Device, req *http.Request, userAPI userapi.UserInternalAPI, device *api.Device,
@ -63,7 +59,10 @@ func GetPushersByLocalpart(
Pushers: []pusherJSON{}, Pushers: []pusherJSON{},
} }
//data := map[string]json.RawMessage;
var data map[string]json.RawMessage
for _, pusher := range queryRes.Pushers { for _, pusher := range queryRes.Pushers {
json.Unmarshal([]byte(pusher.Data), &data)
res.Pushers = append(res.Pushers, pusherJSON{ res.Pushers = append(res.Pushers, pusherJSON{
PushKey: pusher.PushKey, PushKey: pusher.PushKey,
Kind: pusher.Kind, Kind: pusher.Kind,
@ -72,7 +71,7 @@ func GetPushersByLocalpart(
DeviceDisplayName: pusher.DeviceDisplayName, DeviceDisplayName: pusher.DeviceDisplayName,
ProfileTag: pusher.ProfileTag, ProfileTag: pusher.ProfileTag,
Language: pusher.Language, Language: pusher.Language,
Data: pusherDataJSON(pusher.Data), Data: data,
}) })
} }
@ -127,8 +126,7 @@ func SetPusherByLocalpart(
DeviceDisplayName: body.DeviceDisplayName, DeviceDisplayName: body.DeviceDisplayName,
ProfileTag: body.ProfileTag, ProfileTag: body.ProfileTag,
Language: body.Language, Language: body.Language,
URL: body.Data.URL, Data: body.Data,
Format: body.Data.Format,
}, &pusherResponse) }, &pusherResponse)
if err != nil { if err != nil {
@ -164,8 +162,7 @@ func SetPusherByLocalpart(
DeviceDisplayName: body.DeviceDisplayName, DeviceDisplayName: body.DeviceDisplayName,
ProfileTag: body.ProfileTag, ProfileTag: body.ProfileTag,
Language: body.Language, Language: body.Language,
URL: body.Data.URL, Data: body.Data,
Format: body.Data.Format,
}, &pusherResponse) }, &pusherResponse)
if err != nil { if err != nil {

View file

@ -252,8 +252,7 @@ type PerformPusherCreationRequest struct {
DeviceDisplayName string DeviceDisplayName string
ProfileTag string ProfileTag string
Language string Language string
URL string Data map[string]json.RawMessage
Format string
} }
// PerformPusherCreationResponse is the response for PerformPusherCreation // PerformPusherCreationResponse is the response for PerformPusherCreation
@ -270,8 +269,7 @@ type PerformPusherUpdateRequest struct {
DeviceDisplayName string DeviceDisplayName string
ProfileTag string ProfileTag string
Language string Language string
URL string Data map[string]json.RawMessage
Format string
} }
// PerformPusherUpdateResponse is the response for PerformPusherUpdate // PerformPusherUpdateResponse is the response for PerformPusherUpdate
@ -340,12 +338,7 @@ type Pusher struct {
DeviceDisplayName string DeviceDisplayName string
ProfileTag string ProfileTag string
Language string Language string
Data PusherData Data string
}
type PusherData struct {
URL string
Format string
} }
// Account represents a Matrix account on this home server. // Account represents a Matrix account on this home server.

View file

@ -161,7 +161,11 @@ func (a *UserInternalAPI) PerformPusherCreation(ctx context.Context, req *api.Pe
if err != nil { if err != nil {
return err return err
} }
err = a.PusherDB.CreatePusher(ctx, req.Device.SessionID, req.PushKey, req.Kind, req.AppID, req.AppDisplayName, req.DeviceDisplayName, req.ProfileTag, req.Language, req.URL, req.Format, local) jsonData, err := json.Marshal(req.Data)
if err != nil {
return err
}
err = a.PusherDB.CreatePusher(ctx, req.Device.SessionID, req.PushKey, req.Kind, req.AppID, req.AppDisplayName, req.DeviceDisplayName, req.ProfileTag, req.Language, string(jsonData), local)
return err return err
} }
@ -175,7 +179,11 @@ func (a *UserInternalAPI) PerformPusherUpdate(ctx context.Context, req *api.Perf
if err != nil { if err != nil {
return err return err
} }
err = a.PusherDB.UpdatePusher(ctx, req.PushKey, req.Kind, req.AppID, req.AppDisplayName, req.DeviceDisplayName, req.ProfileTag, req.Language, req.URL, req.Format, local) jsonData, err := json.Marshal(req.Data)
if err != nil {
return err
}
err = a.PusherDB.UpdatePusher(ctx, req.PushKey, req.Kind, req.AppID, req.AppDisplayName, req.DeviceDisplayName, req.ProfileTag, req.Language, string(jsonData), local)
return err return err
} }

View file

@ -21,9 +21,9 @@ import (
) )
type Database interface { type Database interface {
CreatePusher(ctx context.Context, sessionId int64, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string) error CreatePusher(ctx context.Context, sessionId int64, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string) error
GetPushersByLocalpart(ctx context.Context, localpart string) ([]api.Pusher, error) GetPushersByLocalpart(ctx context.Context, localpart string) ([]api.Pusher, error)
GetPusherByPushkey(ctx context.Context, pushkey, localpart string) (*api.Pusher, error) GetPusherByPushkey(ctx context.Context, pushkey, localpart string) (*api.Pusher, error)
UpdatePusher(ctx context.Context, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string) error UpdatePusher(ctx context.Context, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string) error
RemovePusher(ctx context.Context, appId, pushkey, localpart string) error RemovePusher(ctx context.Context, appId, pushkey, localpart string) error
} }

View file

@ -52,10 +52,8 @@ CREATE TABLE IF NOT EXISTS pusher_pushers (
pushkey VARCHAR(512) NOT NULL, pushkey VARCHAR(512) NOT NULL,
-- The preferred language for receiving notifications (e.g. 'en' or 'en-US') -- The preferred language for receiving notifications (e.g. 'en' or 'en-US')
lang TEXT, lang TEXT,
-- Required if kind is http. The URL to use to send notifications to. -- A dictionary of information for the pusher implementation itself.
url TEXT, data TEXT
-- The format to use when sending notifications to the Push Gateway.
format TEXT
); );
-- Pushkey must be unique for a given user. -- Pushkey must be unique for a given user.
@ -63,16 +61,16 @@ CREATE UNIQUE INDEX IF NOT EXISTS pusher_app_id_pushkey_localpart_idx ON pusher_
` `
const insertPusherSQL = "" + const insertPusherSQL = "" +
"INSERT INTO pusher_pushers(localpart, session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, url, format) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)" "INSERT INTO pusher_pushers(localpart, session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, data) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"
const selectPushersByLocalpartSQL = "" + const selectPushersByLocalpartSQL = "" +
"SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, url, format FROM pusher_pushers WHERE localpart = $1" "SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, data FROM pusher_pushers WHERE localpart = $1"
const selectPusherByPushkeySQL = "" + const selectPusherByPushkeySQL = "" +
"SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, url, format FROM pusher_pushers WHERE localpart = $1 AND pushkey = $2" "SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, data FROM pusher_pushers WHERE localpart = $1 AND pushkey = $2"
const updatePusherSQL = "" + const updatePusherSQL = "" +
"UPDATE pusher_pushers SET kind = $1, app_id = $2, app_display_name = $3, device_display_name = $4, profile_tag = $5, lang = $6, url = $7, format = $8 WHERE localpart = $9 AND pushkey = $10" "UPDATE pusher_pushers SET kind = $1, app_id = $2, app_display_name = $3, device_display_name = $4, profile_tag = $5, lang = $6, data = $7 WHERE localpart = $8 AND pushkey = $9"
const deletePusherSQL = "" + const deletePusherSQL = "" +
"DELETE FROM pusher_pushers WHERE app_id = $1 AND pushkey = $2 AND localpart = $3" "DELETE FROM pusher_pushers WHERE app_id = $1 AND pushkey = $2 AND localpart = $3"
@ -116,10 +114,10 @@ func (s *pushersStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerN
// Returns nil error success. // Returns nil error success.
func (s *pushersStatements) insertPusher( func (s *pushersStatements) insertPusher(
ctx context.Context, txn *sql.Tx, session_id int64, ctx context.Context, txn *sql.Tx, session_id int64,
pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
stmt := sqlutil.TxStmt(txn, s.insertPusherStmt) stmt := sqlutil.TxStmt(txn, s.insertPusherStmt)
_, err := stmt.ExecContext(ctx, localpart, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format) _, err := stmt.ExecContext(ctx, localpart, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data)
logrus.Debugf("🥳 Created pusher %d", session_id) logrus.Debugf("🥳 Created pusher %d", session_id)
return err return err
} }
@ -138,8 +136,8 @@ func (s *pushersStatements) selectPushersByLocalpart(
for rows.Next() { for rows.Next() {
var pusher api.Pusher var pusher api.Pusher
var sessionid sql.NullInt64 var sessionid sql.NullInt64
var pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format sql.NullString var pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data sql.NullString
err = rows.Scan(&sessionid, &pushkey, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &url, &format) err = rows.Scan(&sessionid, &pushkey, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &data)
if err != nil { if err != nil {
return pushers, err return pushers, err
} }
@ -167,11 +165,8 @@ func (s *pushersStatements) selectPushersByLocalpart(
if lang.Valid { if lang.Valid {
pusher.Language = lang.String pusher.Language = lang.String
} }
if url.Valid && format.Valid { if data.Valid {
pusher.Data = api.PusherData{ pusher.Data = data.String
URL: url.String,
Format: format.String,
}
} }
pusher.UserID = userutil.MakeUserID(localpart, s.serverName) pusher.UserID = userutil.MakeUserID(localpart, s.serverName)
@ -187,10 +182,10 @@ func (s *pushersStatements) selectPusherByPushkey(
) (*api.Pusher, error) { ) (*api.Pusher, error) {
var pusher api.Pusher var pusher api.Pusher
var sessionid sql.NullInt64 var sessionid sql.NullInt64
var key, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format sql.NullString var key, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data sql.NullString
stmt := s.selectPusherByPushkeyStmt stmt := s.selectPusherByPushkeyStmt
err := stmt.QueryRowContext(ctx, localpart, pushkey).Scan(&sessionid, &key, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &url, &format) err := stmt.QueryRowContext(ctx, localpart, pushkey).Scan(&sessionid, &key, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &data)
if err == nil { if err == nil {
if sessionid.Valid { if sessionid.Valid {
@ -217,11 +212,8 @@ func (s *pushersStatements) selectPusherByPushkey(
if lang.Valid { if lang.Valid {
pusher.Language = lang.String pusher.Language = lang.String
} }
if url.Valid && format.Valid { if data.Valid {
pusher.Data = api.PusherData{ pusher.Data = data.String
URL: url.String,
Format: format.String,
}
} }
pusher.UserID = userutil.MakeUserID(localpart, s.serverName) pusher.UserID = userutil.MakeUserID(localpart, s.serverName)
@ -231,10 +223,10 @@ func (s *pushersStatements) selectPusherByPushkey(
} }
func (s *pushersStatements) updatePusher( func (s *pushersStatements) updatePusher(
ctx context.Context, txn *sql.Tx, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, ctx context.Context, txn *sql.Tx, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
stmt := sqlutil.TxStmt(txn, s.updatePusherStmt) stmt := sqlutil.TxStmt(txn, s.updatePusherStmt)
_, err := stmt.ExecContext(ctx, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart, pushkey) _, err := stmt.ExecContext(ctx, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart, pushkey)
return err return err
} }

View file

@ -58,9 +58,9 @@ func NewDatabase(dbProperties *config.DatabaseOptions, serverName gomatrixserver
func (d *Database) CreatePusher( func (d *Database) CreatePusher(
ctx context.Context, session_id int64, ctx context.Context, session_id int64,
pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
return d.pushers.insertPusher(ctx, nil, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart) return d.pushers.insertPusher(ctx, nil, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart)
} }
// GetPushersByLocalpart returns the pushers matching the given localpart. // GetPushersByLocalpart returns the pushers matching the given localpart.
@ -80,10 +80,10 @@ func (d *Database) GetPusherByPushkey(
// UpdatePusher updates the given pusher with the display name. // UpdatePusher updates the given pusher with the display name.
// Returns SQL error if there are problems and nil on success. // Returns SQL error if there are problems and nil on success.
func (d *Database) UpdatePusher( func (d *Database) UpdatePusher(
ctx context.Context, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, ctx context.Context, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
return sqlutil.WithTransaction(d.db, func(txn *sql.Tx) error { return sqlutil.WithTransaction(d.db, func(txn *sql.Tx) error {
return d.pushers.updatePusher(ctx, txn, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart) return d.pushers.updatePusher(ctx, txn, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart)
}) })
} }

View file

@ -38,24 +38,23 @@ CREATE TABLE IF NOT EXISTS pusher_pushers (
device_display_name TEXT, device_display_name TEXT,
pushkey VARCHAR(512), pushkey VARCHAR(512),
lang TEXT, lang TEXT,
url TEXT, data TEXT,
format TEXT,
UNIQUE (app_id, pushkey, localpart) UNIQUE (app_id, pushkey, localpart)
); );
` `
const insertPusherSQL = "" + const insertPusherSQL = "" +
"INSERT INTO pusher_pushers (localpart, session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, url, format)" + "INSERT INTO pusher_pushers (localpart, session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, data)" +
" VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)" " VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"
const selectPushersByLocalpartSQL = "" + const selectPushersByLocalpartSQL = "" +
"SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, url, format FROM pusher_pushers WHERE localpart = $1" "SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, data FROM pusher_pushers WHERE localpart = $1"
const selectPusherByPushkeySQL = "" + const selectPusherByPushkeySQL = "" +
"SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, url, format FROM pusher_pushers WHERE localpart = $1 AND pushkey = $2" "SELECT session_id, pushkey, kind, app_id, app_display_name, device_display_name, profile_tag, lang, data FROM pusher_pushers WHERE localpart = $1 AND pushkey = $2"
const updatePusherSQL = "" + const updatePusherSQL = "" +
"UPDATE pusher_pushers SET kind = $1, app_id = $2, app_display_name = $3, device_display_name = $4, profile_tag = $5, lang = $6, url = $7, format = $8 WHERE localpart = $9 AND pushkey = $10" "UPDATE pusher_pushers SET kind = $1, app_id = $2, app_display_name = $3, device_display_name = $4, profile_tag = $5, lang = $6, data = $7 WHERE localpart = $8 AND pushkey = $9"
const deletePusherSQL = "" + const deletePusherSQL = "" +
"DELETE FROM pusher_pushers WHERE app_id = $1 AND pushkey = $2 AND localpart = $3" "DELETE FROM pusher_pushers WHERE app_id = $1 AND pushkey = $2 AND localpart = $3"
@ -103,10 +102,10 @@ func (s *pushersStatements) prepare(db *sql.DB, writer sqlutil.Writer, server go
// Returns nil error success. // Returns nil error success.
func (s *pushersStatements) insertPusher( func (s *pushersStatements) insertPusher(
ctx context.Context, txn *sql.Tx, session_id int64, ctx context.Context, txn *sql.Tx, session_id int64,
pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
stmt := sqlutil.TxStmt(txn, s.insertPusherStmt) stmt := sqlutil.TxStmt(txn, s.insertPusherStmt)
_, err := stmt.ExecContext(ctx, localpart, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format) _, err := stmt.ExecContext(ctx, localpart, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data)
logrus.Debugf("🥳 Created pusher %d", session_id) logrus.Debugf("🥳 Created pusher %d", session_id)
return err return err
} }
@ -125,8 +124,8 @@ func (s *pushersStatements) selectPushersByLocalpart(
logrus.Debug("Next pusher row...") logrus.Debug("Next pusher row...")
var pusher api.Pusher var pusher api.Pusher
var sessionid sql.NullInt64 var sessionid sql.NullInt64
var pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format sql.NullString var pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data sql.NullString
err = rows.Scan(&sessionid, &pushkey, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &url, &format) err = rows.Scan(&sessionid, &pushkey, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &data)
if err != nil { if err != nil {
return pushers, err return pushers, err
} }
@ -154,11 +153,8 @@ func (s *pushersStatements) selectPushersByLocalpart(
if lang.Valid { if lang.Valid {
pusher.Language = lang.String pusher.Language = lang.String
} }
if url.Valid && format.Valid { if data.Valid {
pusher.Data = api.PusherData{ pusher.Data = data.String
URL: url.String,
Format: format.String,
}
} }
pusher.UserID = userutil.MakeUserID(localpart, s.serverName) pusher.UserID = userutil.MakeUserID(localpart, s.serverName)
@ -175,9 +171,9 @@ func (s *pushersStatements) selectPusherByPushkey(
ctx context.Context, localpart, pushkey string, ctx context.Context, localpart, pushkey string,
) (*api.Pusher, error) { ) (*api.Pusher, error) {
var pusher api.Pusher var pusher api.Pusher
var id, key, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format sql.NullString var id, key, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data sql.NullString
stmt := s.selectPusherByPushkeyStmt stmt := s.selectPusherByPushkeyStmt
err := stmt.QueryRowContext(ctx, localpart, pushkey).Scan(&id, &key, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &url, &format) err := stmt.QueryRowContext(ctx, localpart, pushkey).Scan(&id, &key, &kind, &appid, &appdisplayname, &devicedisplayname, &profiletag, &lang, &data)
if err == nil { if err == nil {
pusher.UserID = userutil.MakeUserID(localpart, s.serverName) pusher.UserID = userutil.MakeUserID(localpart, s.serverName)
if key.Valid { if key.Valid {
@ -201,21 +197,18 @@ func (s *pushersStatements) selectPusherByPushkey(
if lang.Valid { if lang.Valid {
pusher.Language = lang.String pusher.Language = lang.String
} }
if url.Valid && format.Valid { if data.Valid {
pusher.Data = api.PusherData{ pusher.Data = data.String
URL: url.String,
Format: format.String,
}
} }
} }
return &pusher, err return &pusher, err
} }
func (s *pushersStatements) updatePusher( func (s *pushersStatements) updatePusher(
ctx context.Context, txn *sql.Tx, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, ctx context.Context, txn *sql.Tx, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
stmt := sqlutil.TxStmt(txn, s.updatePusherStmt) stmt := sqlutil.TxStmt(txn, s.updatePusherStmt)
_, err := stmt.ExecContext(ctx, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart, pushkey) _, err := stmt.ExecContext(ctx, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart, pushkey)
return err return err
} }

View file

@ -60,9 +60,9 @@ func NewDatabase(dbProperties *config.DatabaseOptions, serverName gomatrixserver
func (d *Database) CreatePusher( func (d *Database) CreatePusher(
ctx context.Context, session_id int64, ctx context.Context, session_id int64,
pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
return d.pushers.insertPusher(ctx, nil, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart) return d.pushers.insertPusher(ctx, nil, session_id, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart)
} }
// GetPushersByLocalpart returns the pushers matching the given localpart. // GetPushersByLocalpart returns the pushers matching the given localpart.
@ -82,10 +82,10 @@ func (d *Database) GetPusherByPushkey(
// UpdatePusher updates the given device with the display name. // UpdatePusher updates the given device with the display name.
// Returns SQL error if there are problems and nil on success. // Returns SQL error if there are problems and nil on success.
func (d *Database) UpdatePusher( func (d *Database) UpdatePusher(
ctx context.Context, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart string, ctx context.Context, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart string,
) error { ) error {
return d.writer.Do(d.db, nil, func(txn *sql.Tx) error { return d.writer.Do(d.db, nil, func(txn *sql.Tx) error {
return d.pushers.updatePusher(ctx, txn, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, url, format, localpart) return d.pushers.updatePusher(ctx, txn, pushkey, kind, appid, appdisplayname, devicedisplayname, profiletag, lang, data, localpart)
}) })
} }