mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Rewrite chat room mentions for federation.
This commit is contained in:
parent
63b658574a
commit
962f0254b1
2 changed files with 31 additions and 13 deletions
|
|
@ -363,6 +363,10 @@ func TestFeatureChatRelayFederation(t *testing.T) {
|
|||
"mention-id": "federated_user/" + hello2.Hello.UserId + "@" + getCloudUrl(server2.URL),
|
||||
"server": server2.URL,
|
||||
},
|
||||
"mention-call": {
|
||||
"type": "call",
|
||||
"id": roomId,
|
||||
},
|
||||
},
|
||||
}
|
||||
federatedChatComment := map[string]any{
|
||||
|
|
@ -390,6 +394,10 @@ func TestFeatureChatRelayFederation(t *testing.T) {
|
|||
"name": "User 2",
|
||||
"mention-id": "federated_user/" + hello2.Hello.UserId + "@" + getCloudUrl(server2.URL),
|
||||
},
|
||||
"mention-call": {
|
||||
"type": "call",
|
||||
"id": federatedRoomId,
|
||||
},
|
||||
},
|
||||
}
|
||||
message := api.StringMap{
|
||||
|
|
|
|||
|
|
@ -648,20 +648,30 @@ func (c *FederationClient) updateComment(comment api.StringMap, localCloudUrl st
|
|||
continue
|
||||
}
|
||||
|
||||
if ptype, found := api.GetStringMapString[string](param, "type"); found && ptype == "user" {
|
||||
if server, found := api.GetStringMapString[string](param, "server"); found && server == localUrl {
|
||||
delete(param, "server")
|
||||
params[key] = param
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
if ptype, found := api.GetStringMapString[string](param, "type"); found {
|
||||
switch ptype {
|
||||
case "user":
|
||||
if server, found := api.GetStringMapString[string](param, "server"); found && server == localUrl {
|
||||
delete(param, "server")
|
||||
params[key] = param
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
|
||||
if _, found := api.GetStringMapString[string](param, "mention-id"); !found {
|
||||
param["mention-id"] = param["id"]
|
||||
param["server"] = remoteUrl
|
||||
params[key] = param
|
||||
changed = true
|
||||
continue
|
||||
if _, found := api.GetStringMapString[string](param, "mention-id"); !found {
|
||||
param["mention-id"] = param["id"]
|
||||
param["server"] = remoteUrl
|
||||
params[key] = param
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
case "call":
|
||||
roomId := c.RoomId()
|
||||
remoteRoomId := c.RemoteRoomId()
|
||||
// TODO: Should we also rewrite the room avatar url in "icon-url"?
|
||||
if c.changeRoomId.Load() && param["id"] == remoteRoomId {
|
||||
param["id"] = roomId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue