Skip to content

Commit 1a3d918

Browse files
authored
Merge pull request #214 from andrii-i/bot_msg_deletion
Allow Users to delete messages if sender is a bot, add optional `bot` bool to user models
2 parents 98ce0ae + ee80194 commit 1a3d918

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/jupyter-chat/src/components/chat-messages.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ export const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
379379
if (model.user.username === message.sender.username) {
380380
setCanEdit(model.updateMessage !== undefined);
381381
setCanDelete(model.deleteMessage !== undefined);
382+
return;
383+
}
384+
if (message.sender.bot) {
385+
setCanDelete(model.deleteMessage !== undefined);
382386
}
383387
} else {
384388
setCanEdit(false);

packages/jupyter-chat/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export interface IUser {
1717
* The string to use to mention a user in the chat.
1818
*/
1919
mention_name?: string;
20+
/**
21+
* Boolean identifying if user is a bot.
22+
*/
23+
bot?: boolean;
2024
}
2125

2226
/**

python/jupyterlab-chat/jupyterlab_chat/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class User(JupyterUser):
7878
mention_name: Optional[str] = None
7979
""" The string to use as mention in chat """
8080

81+
bot: Optional[bool] = None
82+
""" Boolean identifying if user is a bot """
83+
8184

8285
@dataclass
8386
class Attachment:

0 commit comments

Comments
 (0)