conversation: load and send messages
Change-Id: Ia18404ac20239d395af7b0ec871973a9b380ae69
diff --git a/JamiDaemon.js b/JamiDaemon.js
index f60ac50..00583d2 100755
--- a/JamiDaemon.js
+++ b/JamiDaemon.js
@@ -146,23 +146,29 @@
}
account.removeConversation(conversationId)
},
- "ConversationLoaded": (accountId, conversationId) => {
+ "ConversationLoaded": (accountId, conversationId, messages) => {
console.log(`conversationLoaded: ${accountId} ${conversationId}`)
- const account = this.getAccount(accountId)
- if (!account) {
- console.log(`Unknown account ${accountId}`)
- return
- }
- },
- "MessageReceived": (accountId, conversationId, message) => {
- console.log(`messageReceived: ${accountId} ${conversationId}`)
+ console.log(messages)
const account = this.getAccount(accountId)
if (!account) {
console.log(`Unknown account ${accountId}`)
return
}
const conversation = account.getConversation(conversationId)
- if (!conversation) {
+ if (conversation) {
+ conversation.addLoadedMessages(message)
+ }
+ },
+ "MessageReceived": (accountId, conversationId, message) => {
+ console.log(`messageReceived: ${accountId} ${conversationId}`)
+ console.log(message)
+ const account = this.getAccount(accountId)
+ if (!account) {
+ console.log(`Unknown account ${accountId}`)
+ return
+ }
+ const conversation = account.getConversation(conversationId)
+ if (conversation) {
conversation.addMessage(message)
}
},
@@ -319,6 +325,10 @@
}
+ sendMessage(accountId, conversationId, message) {
+ this.dring.sendMessage(accountId, conversationId, message, "")
+ }
+
boolToStr(bool) {
return bool ? "true" : "false"
}