mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
Fix displayname wrongly in invite content
This commit is contained in:
parent
5721982c14
commit
f8c43b4a05
|
|
@ -324,19 +324,18 @@ func SendInvite(
|
||||||
}
|
}
|
||||||
|
|
||||||
// We already received the return value, so no need to check for an error here.
|
// We already received the return value, so no need to check for an error here.
|
||||||
response, _ := sendInvite(req.Context(), profileAPI, device, roomID, body.UserID, body.Reason, cfg, rsAPI, asAPI, evTime)
|
response, _ := sendInvite(req.Context(), device, roomID, body.UserID, body.Reason, cfg, rsAPI, evTime)
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendInvite sends an invitation to a user. Returns a JSONResponse and an error
|
// sendInvite sends an invitation to a user. Returns a JSONResponse and an error
|
||||||
func sendInvite(
|
func sendInvite(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
profileAPI userapi.ClientUserAPI,
|
|
||||||
device *userapi.Device,
|
device *userapi.Device,
|
||||||
roomID, userID, reason string,
|
roomID, userID, reason string,
|
||||||
cfg *config.ClientAPI,
|
cfg *config.ClientAPI,
|
||||||
rsAPI roomserverAPI.ClientRoomserverAPI,
|
rsAPI roomserverAPI.ClientRoomserverAPI,
|
||||||
asAPI appserviceAPI.AppServiceInternalAPI, evTime time.Time,
|
evTime time.Time,
|
||||||
) (util.JSONResponse, error) {
|
) (util.JSONResponse, error) {
|
||||||
validRoomID, err := spec.NewRoomID(roomID)
|
validRoomID, err := spec.NewRoomID(roomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -359,13 +358,7 @@ func sendInvite(
|
||||||
JSON: spec.InvalidParam("UserID is invalid"),
|
JSON: spec.InvalidParam("UserID is invalid"),
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
profile, err := loadProfile(ctx, userID, cfg, profileAPI, asAPI)
|
|
||||||
if err != nil {
|
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusInternalServerError,
|
|
||||||
JSON: spec.InternalServerError{},
|
|
||||||
}, err
|
|
||||||
}
|
|
||||||
identity, err := cfg.Matrix.SigningIdentityFor(device.UserDomain())
|
identity, err := cfg.Matrix.SigningIdentityFor(device.UserDomain())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
@ -375,16 +368,14 @@ func sendInvite(
|
||||||
}
|
}
|
||||||
err = rsAPI.PerformInvite(ctx, &api.PerformInviteRequest{
|
err = rsAPI.PerformInvite(ctx, &api.PerformInviteRequest{
|
||||||
InviteInput: roomserverAPI.InviteInput{
|
InviteInput: roomserverAPI.InviteInput{
|
||||||
RoomID: *validRoomID,
|
RoomID: *validRoomID,
|
||||||
Inviter: *inviter,
|
Inviter: *inviter,
|
||||||
Invitee: *invitee,
|
Invitee: *invitee,
|
||||||
DisplayName: profile.DisplayName,
|
Reason: reason,
|
||||||
AvatarURL: profile.AvatarURL,
|
IsDirect: false,
|
||||||
Reason: reason,
|
KeyID: identity.KeyID,
|
||||||
IsDirect: false,
|
PrivateKey: identity.PrivateKey,
|
||||||
KeyID: identity.KeyID,
|
EventTime: evTime,
|
||||||
PrivateKey: identity.PrivateKey,
|
|
||||||
EventTime: evTime,
|
|
||||||
},
|
},
|
||||||
InviteRoomState: nil, // ask the roomserver to draw up invite room state for us
|
InviteRoomState: nil, // ask the roomserver to draw up invite room state for us
|
||||||
SendAsServer: string(device.UserDomain()),
|
SendAsServer: string(device.UserDomain()),
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ func SendServerNotice(
|
||||||
}
|
}
|
||||||
if !membershipRes.IsInRoom {
|
if !membershipRes.IsInRoom {
|
||||||
// re-invite the user
|
// re-invite the user
|
||||||
res, err := sendInvite(ctx, userAPI, senderDevice, roomID, r.UserID, "Server notice room", cfgClient, rsAPI, asAPI, time.Now())
|
res, err := sendInvite(ctx, senderDevice, roomID, r.UserID, "Server notice room", cfgClient, rsAPI, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,16 +50,14 @@ type PerformLeaveResponse struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type InviteInput struct {
|
type InviteInput struct {
|
||||||
RoomID spec.RoomID
|
RoomID spec.RoomID
|
||||||
Inviter spec.UserID
|
Inviter spec.UserID
|
||||||
Invitee spec.UserID
|
Invitee spec.UserID
|
||||||
DisplayName string
|
Reason string
|
||||||
AvatarURL string
|
IsDirect bool
|
||||||
Reason string
|
KeyID gomatrixserverlib.KeyID
|
||||||
IsDirect bool
|
PrivateKey ed25519.PrivateKey
|
||||||
KeyID gomatrixserverlib.KeyID
|
EventTime time.Time
|
||||||
PrivateKey ed25519.PrivateKey
|
|
||||||
EventTime time.Time
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PerformInviteRequest struct {
|
type PerformInviteRequest struct {
|
||||||
|
|
|
||||||
|
|
@ -503,16 +503,14 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
|
|
||||||
err = c.RSAPI.PerformInvite(ctx, &api.PerformInviteRequest{
|
err = c.RSAPI.PerformInvite(ctx, &api.PerformInviteRequest{
|
||||||
InviteInput: api.InviteInput{
|
InviteInput: api.InviteInput{
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
Inviter: userID,
|
Inviter: userID,
|
||||||
Invitee: *inviteeUserID,
|
Invitee: *inviteeUserID,
|
||||||
DisplayName: createRequest.UserDisplayName,
|
Reason: "",
|
||||||
AvatarURL: createRequest.UserAvatarURL,
|
IsDirect: createRequest.IsDirect,
|
||||||
Reason: "",
|
KeyID: createRequest.KeyID,
|
||||||
IsDirect: createRequest.IsDirect,
|
PrivateKey: createRequest.PrivateKey,
|
||||||
KeyID: createRequest.KeyID,
|
EventTime: createRequest.EventTime,
|
||||||
PrivateKey: createRequest.PrivateKey,
|
|
||||||
EventTime: createRequest.EventTime,
|
|
||||||
},
|
},
|
||||||
InviteRoomState: globalStrippedState,
|
InviteRoomState: globalStrippedState,
|
||||||
SendAsServer: string(userID.Domain()),
|
SendAsServer: string(userID.Domain()),
|
||||||
|
|
|
||||||
|
|
@ -144,11 +144,9 @@ func (r *Inviter) PerformInvite(
|
||||||
}
|
}
|
||||||
|
|
||||||
content := gomatrixserverlib.MemberContent{
|
content := gomatrixserverlib.MemberContent{
|
||||||
Membership: spec.Invite,
|
Membership: spec.Invite,
|
||||||
DisplayName: req.InviteInput.DisplayName,
|
Reason: req.InviteInput.Reason,
|
||||||
AvatarURL: req.InviteInput.AvatarURL,
|
IsDirect: req.InviteInput.IsDirect,
|
||||||
Reason: req.InviteInput.Reason,
|
|
||||||
IsDirect: req.InviteInput.IsDirect,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = proto.SetContent(content); err != nil {
|
if err = proto.SetContent(content); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue