Skip to content

Commit

Permalink
feat: reply to StatusRequest (#26)
Browse files Browse the repository at this point in the history
Reply to StatusRequest in the messagepickup protocol
For ATL-4883
  • Loading branch information
FabioPinheiro committed Jul 3, 2023
1 parent d2c5ce5 commit 28ee891
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,29 @@ object PickupExecuter
case `piuriMessagesReceived` => plaintextMessage.toMessagesReceived
case `piuriLiveModeChange` => plaintextMessage.toLiveModeChange
}).map {
case m: StatusRequest => ZIO.succeed(NoReply) // FIXME
case m: Status => ZIO.logInfo("Status") *> ZIO.succeed(NoReply)
case m: StatusRequest =>
for {
_ <- ZIO.logInfo("StatusRequest")
repoDidAccount <- ZIO.service[UserAccountRepo]
didRequestingMessages = m.from.asFROMTO
mDidAccount <- repoDidAccount.getDidAccount(didRequestingMessages.toDID)
msgHash = mDidAccount match
case None => ??? // TODO FIXME
case Some(didAccount) => didAccount.messagesRef.filter(_.state == false).map(_.hash)
status = Status(
thid = m.id,
from = m.to.asFROM,
to = m.from.asTO,
recipient_did = m.recipient_did,
message_count = msgHash.size,
longest_waited_seconds = None, // TODO
newest_received_time = None, // TODO
oldest_received_time = None, // TODO
total_bytes = None, // TODO
live_delivery = None, // TODO
)
} yield Reply(status.toPlaintextMessage)
case m: Status => ZIO.logInfo("Status") *> ZIO.succeed(NoReply)
case m: DeliveryRequest =>
for {
_ <- ZIO.logInfo("DeliveryRequest")
Expand Down

0 comments on commit 28ee891

Please sign in to comment.