fix: three code review issues — leaveGroup duplicate, as any casts, federation ownership fallback

- Remove redundant `leaveGroup` API method from client.ts (duplicated `leave`); update MessageList.tsx WelcomeHeader to call `api.dm.leave` directly
- Add optional `type` field to shared `Message` interface so `MessageWithUser` carries it; remove `(msg as any).type` casts in `isSameGroup` and the render branch in MessageList.tsx
- Fix `processOwnershipTransferEvent` in federation.ts: replace `channel.ownerId` fallbacks (pre-update, old owner) with `event.ownership.newOwner.homeUserId` in the db update, dm_owner_updated broadcast, and both system message content payloads
This commit is contained in:
Jannis Braun
2026-03-27 05:50:38 +01:00
parent c3191be4e7
commit 04c665e0f7
4 changed files with 8 additions and 10 deletions
+4 -4
View File
@@ -1965,7 +1965,7 @@ function processOwnershipTransferEvent(
db.update(schema.dmChannels)
.set({
ownerId: newOwnerLocal?.id ?? channel.ownerId,
ownerId: newOwnerLocal?.id ?? null,
ownerHomeUserId: event.ownership.newOwner.homeUserId,
ownerHomeInstance: event.ownership.newOwner.homeInstance,
})
@@ -1975,7 +1975,7 @@ function processOwnershipTransferEvent(
connectionManager.sendToDmMembers(channel.id, {
type: 'dm_owner_updated',
dmChannelId: channel.id,
newOwnerId: newOwnerLocal?.id ?? channel.ownerId!,
newOwnerId: newOwnerLocal?.id ?? event.ownership.newOwner.homeUserId,
});
const prevOwnerLocal = event.ownership.previousOwner
@@ -1991,7 +1991,7 @@ function processOwnershipTransferEvent(
userId: prevOwnerId,
content: JSON.stringify({
event: 'owner_changed',
newOwnerId: newOwnerLocal?.id ?? channel.ownerId,
newOwnerId: newOwnerLocal?.id ?? event.ownership.newOwner.homeUserId,
newOwnerDisplayName: newOwnerLocal?.displayName ?? newOwnerBaseName,
}),
type: 'system',
@@ -2006,7 +2006,7 @@ function processOwnershipTransferEvent(
userId: prevOwnerId,
content: JSON.stringify({
event: 'owner_changed',
newOwnerId: newOwnerLocal?.id ?? channel.ownerId,
newOwnerId: newOwnerLocal?.id ?? event.ownership.newOwner.homeUserId,
newOwnerDisplayName: newOwnerLocal?.displayName ?? newOwnerBaseName,
}),
type: 'system',