Skip to content

Commit

Permalink
chore: move log code to default callback
Browse files Browse the repository at this point in the history
Signed-off-by: Colton Wolkins (Indicio work address) <[email protected]>
  • Loading branch information
TheTechmage committed Jan 18, 2024
1 parent 4d298fe commit f22d60b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions didcomm_messaging/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,17 @@ async def setup_relay(
return new_did


async def _message_callback(msg: Message) -> None:
if msg.type == "https://didcomm.org/basicmessage/2.0/message":
logmsg = msg.body["content"].replace("\n", " ").replace("\r", "")
LOG.info("Got message: %s", logmsg)


async def fetch_relayed_messages(
dmp: DIDCommMessaging,
my_did: DID,
relay_did: DID,
callback: Callable[[Message], Awaitable[None]] = None,
callback: Callable[[Message], Awaitable[None]] = _message_callback,
) -> List[Message]:
"""Fetch stored messages from the relay."""

Expand Down Expand Up @@ -389,10 +395,6 @@ async def fetch_relayed_messages(
if callback:
await callback(msg)

if msg.type == "https://didcomm.org/basicmessage/2.0/message":
logmsg = msg.body["content"].replace("\n", " ").replace("\r", "")
LOG.info(f"Got message: %s", logmsg)

message = Message(
type="https://didcomm.org/messagepickup/3.0/messages-received",
id=str(uuid.uuid4()),
Expand Down

0 comments on commit f22d60b

Please sign in to comment.