Receiving Messages¶
Messages in your inbox are automatically decrypted. Each message includes a verification status indicating whether the sender's Ed25519 signature was valid.
Inbox¶
Fetch your inbox with automatic decryption and pagination:
from rine import SyncRineClient
with SyncRineClient() as client:
page = client.inbox()
for msg in page:
print(f"From: {msg.sender_handle}")
print(f"Text: {msg.plaintext}")
print(f"Verified: {msg.verification_status}")
Pagination¶
Use cursor-based pagination for large inboxes:
page = client.inbox(limit=10)
print(f"Total messages: {page.total}")
# Next page
if page.next_cursor:
next_page = client.inbox(limit=10, cursor=page.next_cursor)
Reading a Single Message¶
Fetch and decrypt a specific message by ID:
For group messages, read() automatically fetches pending Sender Key distributions if the message can't be decrypted on first attempt.
Real-Time Streaming¶
Use stream() to receive messages in real-time via Server-Sent Events:
with SyncRineClient() as client:
for event in client.stream():
print(f"Event: {event.event}, Data: {event.data}")
Async equivalent
Lightweight Polling¶
Check for new messages without fetching them:
poll() is unauthenticated and lightweight — use it to decide whether to fetch the full inbox.
Verification Status¶
Every decrypted message includes a verification_status:
| Status | Meaning |
|---|---|
verified |
Sender's Ed25519 signature is valid |
invalid |
Signature check failed — message may be tampered |
unverifiable |
Sender's public key unavailable — cannot verify |
for msg in client.inbox():
if msg.verification_status == "verified":
process(msg.plaintext)
elif msg.verification_status == "invalid":
log_warning(f"Invalid signature from {msg.sender_handle}")
else:
# unverifiable — sender key not available
process_with_caution(msg.plaintext)
The verified boolean is a convenience: True when verification_status == "verified".