Skip to content

Say which conversation an attachment transfer belongs to - #165

Open
Bilb wants to merge 2 commits into
session-foundation:clientfrom
Bilb:feat/attachment-progress-conversation
Open

Bilb wants to merge 2 commits into
session-foundation:clientfrom
Bilb:feat/attachment-progress-conversation

Conversation

@Bilb

@Bilb Bilb commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

A progress report broadcast through callbacks::attachment_progress came with the conversation beside it, but one handed to the on_progress handler a caller passed to attachment_data or save_attachment carried only message_id. So an application routing a report to the conversation view it belongs to had to look the message up again — for every tick of every transfer.

AttachmentProgress now carries conversation_id. The Client knows it at both construction sites, so nothing extra is looked up: _attachment_pointer gains the value by joining messages onto the query it was already making.

The second commit then takes the leading ConversationId parameter off callbacks::attachment_progress, which the field makes a duplicate. display_picture_progress keeps its parameter — it has no struct to put one on, which is the same reason it carries no message or index.

I checked the consumers before changing the signature: session-cli never registers this callback, it only passes on_progress to attachment_data. The only consumer is session-app's bridge, which is ours and updates alongside.

Tests: the existing save and auto-download cases now assert the conversation on the reports they already collect, and the auto-download case asserts the broadcast field is the value the parameter used to carry.

Built and run against the client suite: 134 cases, 1010 assertions, passing.

Independent of the two PRs alongside it and mergeable in any order. It and #166 both add #include <session/client/conversation_id.hpp> to attachment.hpp; identical additions, so whichever merges second is a no-op there.

Note: tests/static-bundle-test fails to link on client already, before this change (undefined reference to SQLite::Database::exec). Unrelated and untouched.

A report handed to save_attachment's or attachment_data's progress
handler carried only the message id, so a caller had to look the message
up to find out whether the transfer was for anything it was showing.
The conversation is already known at both sites, so the report carries
it.

callbacks::attachment_progress keeps its leading ConversationId: it is
now the same value as the field, but other consumers take it.
It is on the report now, so the parameter said the same thing twice. A
handler that files these by conversation needs the value wherever a
report comes from, and the one handed to attachment_data or
save_attachment has no second argument to carry it - so the struct is the
only place that can hold it for both.

display_picture_progress keeps its parameter: it has no struct to put one
on, which is the same reason it has no message or index.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant