aboutsummaryrefslogtreecommitdiff
path: root/userapi/internal/api.go
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-10-21 10:48:25 +0200
committerGitHub <noreply@github.com>2022-10-21 10:48:25 +0200
commite57b30172227c4a0b7de15ba635b20921dedda5e (patch)
treefa73a898b6a58d2250e2e7c6fd7b7f5df8b0f7f2 /userapi/internal/api.go
parent40cfb9a4ea23f1c9214553255feb296c2578b213 (diff)
Set `display_name` and/or `avatar_url` for server notices (#2820)
This should fix #2815 by making sure we actually set the `display_name` and/or `avatar_url` and create the needed membership event. To avoid creating a new membership event when starting Dendrite, `SetAvatarURL` and `SetDisplayName` now return a `Changed` value, which also makes the regular endpoints idempotent.
Diffstat (limited to 'userapi/internal/api.go')
-rw-r--r--userapi/internal/api.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/userapi/internal/api.go b/userapi/internal/api.go
index 2f7795df..63044eed 100644
--- a/userapi/internal/api.go
+++ b/userapi/internal/api.go
@@ -170,7 +170,7 @@ func (a *UserInternalAPI) PerformAccountCreation(ctx context.Context, req *api.P
return nil
}
- if err = a.DB.SetDisplayName(ctx, req.Localpart, req.Localpart); err != nil {
+ if _, _, err = a.DB.SetDisplayName(ctx, req.Localpart, req.Localpart); err != nil {
return err
}
@@ -813,7 +813,10 @@ func (a *UserInternalAPI) QueryPushRules(ctx context.Context, req *api.QueryPush
}
func (a *UserInternalAPI) SetAvatarURL(ctx context.Context, req *api.PerformSetAvatarURLRequest, res *api.PerformSetAvatarURLResponse) error {
- return a.DB.SetAvatarURL(ctx, req.Localpart, req.AvatarURL)
+ profile, changed, err := a.DB.SetAvatarURL(ctx, req.Localpart, req.AvatarURL)
+ res.Profile = profile
+ res.Changed = changed
+ return err
}
func (a *UserInternalAPI) QueryNumericLocalpart(ctx context.Context, res *api.QueryNumericLocalpartResponse) error {
@@ -847,8 +850,11 @@ func (a *UserInternalAPI) QueryAccountByPassword(ctx context.Context, req *api.Q
}
}
-func (a *UserInternalAPI) SetDisplayName(ctx context.Context, req *api.PerformUpdateDisplayNameRequest, _ *struct{}) error {
- return a.DB.SetDisplayName(ctx, req.Localpart, req.DisplayName)
+func (a *UserInternalAPI) SetDisplayName(ctx context.Context, req *api.PerformUpdateDisplayNameRequest, res *api.PerformUpdateDisplayNameResponse) error {
+ profile, changed, err := a.DB.SetDisplayName(ctx, req.Localpart, req.DisplayName)
+ res.Profile = profile
+ res.Changed = changed
+ return err
}
func (a *UserInternalAPI) QueryLocalpartForThreePID(ctx context.Context, req *api.QueryLocalpartForThreePIDRequest, res *api.QueryLocalpartForThreePIDResponse) error {