From 7696ec37de8ce2b94b997e151b47a5d7df05a3eb Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Thu, 19 Oct 2023 22:10:26 +0800 Subject: [PATCH] update refer --- app/src/conversation/conversation.ts | 3 +++ manager/conversation/shared.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/src/conversation/conversation.ts b/app/src/conversation/conversation.ts index 696e0ef3..2183efb3 100644 --- a/app/src/conversation/conversation.ts +++ b/app/src/conversation/conversation.ts @@ -11,6 +11,7 @@ export class Conversation { public id: number; public data: Message[]; public end: boolean; + public refer: string; public constructor(id: number, callback?: ConversationCallback) { if (callback) this.setCallback(callback); @@ -19,12 +20,14 @@ export class Conversation { this.id = id; this.end = true; this.connection = new Connection(this.id); + this.refer = ""; if (id === -1 && this.idx === -1) { event.bind(({ refer, data }) => { console.log( `[conversation] load from sharing event (ref: ${refer}, length: ${data.length})`, ); + this.refer = refer; this.load(data); }); } diff --git a/manager/conversation/shared.go b/manager/conversation/shared.go index 320421f4..5597021f 100644 --- a/manager/conversation/shared.go +++ b/manager/conversation/shared.go @@ -128,3 +128,17 @@ func UseSharedConversation(db *sql.DB, user *auth.User, hash string) *Conversati Message: shared.Messages, } } + +func (c *Conversation) LoadSharing(db *sql.DB, hash string) { + if strings.TrimSpace(hash) == "" { + return + } + + shared, err := GetSharedConversation(db, hash) + if err != nil { + return + } + + c.Message = shared.Messages + c.Name = shared.Name +}