mirror of
https://github.com/coaidev/coai.git
synced 2025-05-31 10:50:21 +09:00
update refer
This commit is contained in:
parent
9eb021a52e
commit
7696ec37de
@ -11,6 +11,7 @@ export class Conversation {
|
|||||||
public id: number;
|
public id: number;
|
||||||
public data: Message[];
|
public data: Message[];
|
||||||
public end: boolean;
|
public end: boolean;
|
||||||
|
public refer: string;
|
||||||
|
|
||||||
public constructor(id: number, callback?: ConversationCallback) {
|
public constructor(id: number, callback?: ConversationCallback) {
|
||||||
if (callback) this.setCallback(callback);
|
if (callback) this.setCallback(callback);
|
||||||
@ -19,12 +20,14 @@ export class Conversation {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.end = true;
|
this.end = true;
|
||||||
this.connection = new Connection(this.id);
|
this.connection = new Connection(this.id);
|
||||||
|
this.refer = "";
|
||||||
|
|
||||||
if (id === -1 && this.idx === -1) {
|
if (id === -1 && this.idx === -1) {
|
||||||
event.bind(({ refer, data }) => {
|
event.bind(({ refer, data }) => {
|
||||||
console.log(
|
console.log(
|
||||||
`[conversation] load from sharing event (ref: ${refer}, length: ${data.length})`,
|
`[conversation] load from sharing event (ref: ${refer}, length: ${data.length})`,
|
||||||
);
|
);
|
||||||
|
this.refer = refer;
|
||||||
this.load(data);
|
this.load(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -128,3 +128,17 @@ func UseSharedConversation(db *sql.DB, user *auth.User, hash string) *Conversati
|
|||||||
Message: shared.Messages,
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user