feat: chat stream messages
This commit is contained in:
1 parent
bc71fa4d59
commit
5d2f7609f4
5 files changed
+131
-10
No files matched your search
@@ -107,7 +107,9 @@ class ChatMixin:
|
||||
now = int(datetime.now().timestamp())
|
||||
|
||||
if isinstance(content, Stream):
|
||||
initial_content = "..."
|
||||
initial_format = format
|
||||
format = format and "steam-" + format or "stream"
|
||||
initial_content = str(content.id)
|
||||
else:
|
||||
initial_content = content
|
||||
|
||||
@@ -169,9 +171,11 @@ class ChatMixin:
|
||||
notify_users()
|
||||
|
||||
def chunk_fn (chunk):
|
||||
message.content = content.content + "..."
|
||||
pass
|
||||
async def end_fn ():
|
||||
message.format = initial_format
|
||||
message.content = content.content
|
||||
|
||||
if db.is_instance(message):
|
||||
await message.save()
|
||||
await notify_agents()
|
||||
@@ -228,6 +232,7 @@ class ChatMixin:
|
||||
|
||||
def notify_message_to_user(self, user_id, message, update=False):
|
||||
if user_id in self.user_connections:
|
||||
# TODO: Server's responsibility, and Message.to_json responsibility as well
|
||||
user_message = {
|
||||
'action': 'chat-message',
|
||||
'id': message.id,
|
||||
@@ -235,6 +240,8 @@ class ChatMixin:
|
||||
'time': message.time,
|
||||
'sender': message.sender,
|
||||
'kind': message.kind,
|
||||
'subkind': message.subkind,
|
||||
'format': message.format,
|
||||
'content': message.content,
|
||||
'threadId': message.thread_id,
|
||||
'update': update,
|
||||
|
||||
Reference in new issue
Block a user