diff --git a/src/chat_sdk/client.nim b/src/chat_sdk/client.nim index 66ad952..26dbce1 100644 --- a/src/chat_sdk/client.nim +++ b/src/chat_sdk/client.nim @@ -12,7 +12,8 @@ import # Foreign std/sequtils, strformat, strutils, - tables + tables, + types import #local conversation_store, @@ -37,8 +38,8 @@ logScope: type MessageCallback*[T] = proc(conversation: Conversation, msg: T): Future[void] {.async.} NewConvoCallback* = proc(conversation: Conversation): Future[void] {.async.} - ReadReceiptCallback* = proc(conversation: Conversation, - msgId: string): Future[void] {.async.} + DeliveryAckCallback* = proc(conversation: Conversation, + msgId: MessageId): Future[void] {.async.} type KeyEntry* = object @@ -56,7 +57,7 @@ type Client* = ref object newMessageCallbacks: seq[MessageCallback[ContentFrame]] newConvoCallbacks: seq[NewConvoCallback] - readReceiptCallbacks: seq[ReadReceiptCallback] + deliveryAckCallbacks: seq[DeliveryAckCallback] ################################################# # Constructors @@ -136,12 +137,12 @@ proc notifyNewConversation(client: Client, convo: Conversation) = for cb in client.newConvoCallbacks: discard cb(convo) -proc onReadReceipt*(client: Client, callback: ReadReceiptCallback) = - client.readReceiptCallbacks.add(callback) +proc onDeliveryAck*(client: Client, callback: DeliveryAckCallback) = + client.deliveryAckCallbacks.add(callback) -proc notifyReadReceipt(client: Client, convo: Conversation, +proc notifyDeliveryAck(client: Client, convo: Conversation, messageId: MessageId) = - for cb in client.readReceiptCallbacks: + for cb in client.deliveryAckCallbacks: discard cb(convo, messageId) ################################################# @@ -213,7 +214,7 @@ proc newPrivateConversation*(client: Client, let deliveryAckCb = proc( conversation: Conversation, msgId: string): Future[void] {.async.} = - client.notifyReadReceipt(conversation, msgId) + client.notifyDeliveryAck(conversation, msgId) let convo = initPrivateV1(client.identity(), destPubkey, "default", deliveryAckCb) client.addConversation(convo) diff --git a/src/chat_sdk/conversation_store.nim b/src/chat_sdk/conversation_store.nim index 4eb7493..ce89a0a 100644 --- a/src/chat_sdk/conversation_store.nim +++ b/src/chat_sdk/conversation_store.nim @@ -17,5 +17,5 @@ type proc notifyNewMessage(self: Self, convo: Conversation, content: ContentFrame) - proc notifyReadReceipt(self: Self, convo: Conversation, + proc notifyDeliveryAck(self: Self, convo: Conversation, msgId: MessageId) diff --git a/src/chat_sdk/inbox.nim b/src/chat_sdk/inbox.nim index df1ca53..fe933dc 100644 --- a/src/chat_sdk/inbox.nim +++ b/src/chat_sdk/inbox.nim @@ -75,7 +75,7 @@ proc createPrivateV1FromInvite*[T: ConversationStore](client: T, let deliveryAckCb = proc( conversation: Conversation, msgId: string): Future[void] {.async.} = - client.notifyReadReceipt(conversation, msgId) + client.notifyDeliveryAck(conversation, msgId) let convo = initPrivateV1(client.identity(), destPubkey, "default", deliveryAckCb) notice "Creating PrivateV1 conversation", client = client.getId(), diff --git a/src/nim_chat_poc.nim b/src/nim_chat_poc.nim index a207e43..fdb299b 100644 --- a/src/nim_chat_poc.nim +++ b/src/nim_chat_poc.nim @@ -69,7 +69,7 @@ proc main() {.async.} = "https://waku.org/theme/image/logo-black.svg")) ) - saro.onReadReceipt(proc(convo: Conversation, msgId: string) {.async.} = + saro.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} = echo " Saro -- Read Receipt for " & msgId ) @@ -86,7 +86,7 @@ proc main() {.async.} = echo " ------> Raya :: New Conversation: " & convo.id() await convo.sendMessage(raya.ds, initTextFrame("Hello").toContentFrame()) ) - raya.onReadReceipt(proc(convo: Conversation, msgId: string) {.async.} = + raya.onDeliveryAck(proc(convo: Conversation, msgId: string) {.async.} = echo " raya -- Read Receipt for " & msgId )