mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-31 10:43:10 -06:00
Set the avatar on account creation
This commit is contained in:
parent
04ecd975a9
commit
fe6a47af28
|
|
@ -139,7 +139,7 @@ func SendServerNotice(
|
||||||
roomVersion = gomatrixserverlib.RoomVersionV6
|
roomVersion = gomatrixserverlib.RoomVersionV6
|
||||||
)
|
)
|
||||||
|
|
||||||
senderDevice, err := getSenderDevice(ctx, userAPI, cfgClient)
|
senderDevice, err := getSenderDevice(ctx, userAPI, accountsDB, cfgClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("unable to get device")
|
logrus.WithError(err).Error("unable to get device")
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
|
|
@ -269,7 +269,12 @@ func (r sendServerNoticeRequest) valid() (ok bool) {
|
||||||
|
|
||||||
// getSenderDevice creates a user account to be used when sending server notices.
|
// getSenderDevice creates a user account to be used when sending server notices.
|
||||||
// It returns an userapi.Device, which is used for building the event
|
// It returns an userapi.Device, which is used for building the event
|
||||||
func getSenderDevice(ctx context.Context, userAPI userapi.UserInternalAPI, cfg *config.ClientAPI) (*userapi.Device, error) {
|
func getSenderDevice(
|
||||||
|
ctx context.Context,
|
||||||
|
userAPI userapi.UserInternalAPI,
|
||||||
|
accountDB accounts.Database,
|
||||||
|
cfg *config.ClientAPI,
|
||||||
|
) (*userapi.Device, error) {
|
||||||
var accRes userapi.PerformAccountCreationResponse
|
var accRes userapi.PerformAccountCreationResponse
|
||||||
// create account if it doesn't exist
|
// create account if it doesn't exist
|
||||||
err := userAPI.PerformAccountCreation(ctx, &userapi.PerformAccountCreationRequest{
|
err := userAPI.PerformAccountCreation(ctx, &userapi.PerformAccountCreationRequest{
|
||||||
|
|
@ -281,6 +286,12 @@ func getSenderDevice(ctx context.Context, userAPI userapi.UserInternalAPI, cfg *
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the avatarurl for the user
|
||||||
|
if err = accountDB.SetAvatarURL(ctx, cfg.Matrix.ServerNotices.LocalPart, cfg.Matrix.ServerNotices.AvatarURL); err != nil {
|
||||||
|
util.GetLogger(ctx).WithError(err).Error("accountDB.SetAvatarURL failed")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we got existing devices
|
// Check if we got existing devices
|
||||||
deviceRes := &userapi.QueryDevicesResponse{}
|
deviceRes := &userapi.QueryDevicesResponse{}
|
||||||
err = userAPI.QueryDevices(ctx, &userapi.QueryDevicesRequest{
|
err = userAPI.QueryDevices(ctx, &userapi.QueryDevicesRequest{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue