mirror of
https://github.com/logos-messaging/nim-chat-poc.git
synced 2026-01-02 14:13:10 +00:00
Rename to deliveryAck
This commit is contained in:
parent
c151548516
commit
a708a4e966
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user