Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/util/entities/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,12 @@ export class Channel extends BaseClass {
} else {
await emitEvent({
event: "CHANNEL_CREATE",
data: channel_dto,
data: channel_dto.excludedRecipients([creator_user_id]),
user_id: creator_user_id,
});
}

if (recipients.length === 1) return channel_dto;
else return channel_dto.excludedRecipients([creator_user_id]);
if (recipients.length === 1) return channel_dto.excludedRecipients([creator_user_id]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to test, but iirc this causes discord clients to crash (they need at least one recipient)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(specifically causes a crash in case there's a DM where the other user's account has been deleted)

Copy link
Copy Markdown
Contributor Author

@LW-Davide LW-Davide Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a check in case the account is deleted, Discord doesn't like the creator to be in the recipients and causes bugs.

After adding a new friend & opening the DM:
image

(It fixes itself with a page reload, but it's still annoying)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the account is deleted, the relation will return exactly one recipient, which is exactly what this code was trying to work around iirc (as all user data is deleted together with the author)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but it's causing a bug for non-deleted users.

Also found another issue, when trying to delete an account:
update or delete on table "users" violates foreign key constraint "FK_8ff3d1961a48b693810c9f99853" on table "user_settings_protos" Key (id)=(1473723585167176120) is still referenced from table "user_settings_protos".

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the easy solution, i think @ChrisChrome still has that in uncommitted changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added another commit, which solves the user deletion error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tested the two patches, and the Discord client doesn't crash, the chat itself becomes a "self-chat" after the second user gets deleted

image

Is a "user deleted" function implemented? Or the chat should just disappear?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few commits to handle deleted users. If you can, please check them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the result on client side when a user is deleted:

DS:
image
image

Fermi:
image

}

static async removeRecipientFromChannel(channel: Channel, user_id: string) {
Expand Down
Loading