feat(chat): Forward the file of a media viewer message to another conversation by ToteMeiSter · Pull Request #2774 · nextcloud/talk-ios · GitHub
Skip to content

feat(chat): Forward the file of a media viewer message to another conversation - #2774

Open
ToteMeiSter wants to merge 6 commits into
nextcloud:mainfrom
ToteMeiSter:pr/forward-file-to-conversation
Open

ToteMeiSter wants to merge 6 commits into
nextcloud:mainfrom
ToteMeiSter:pr/forward-file-to-conversation

Conversation

@ToteMeiSter

Copy link
Copy Markdown
Contributor

Fixes #2773

Depends on #2772: until it is merged, this PR also shows its two commits. The own commits of this PR are the last four.

What

The media viewer gets a "Forward" button. The file of the shown message is shared into the chosen conversation with the account of the message; nothing is uploaded again.

Before

The toolbar of the viewer held a flexible space and the draw button (NCMediaViewerViewController.swift#L439-L445). ShareViewController could forward a text and an object share (ShareViewController.h#L27-L28); ShareConfirmationViewController knew the types text, item and object share (ShareConfirmationViewController.swift#L71).

Change

  • Button and flow in the viewer: forwardButton is the first item of the toolbar (L102-L110, L462-L464). canForward (L443-L447) offers it only for a message with a file path of the account of the viewer that is not deleted, not federated and not classified. forwardCurrentMedia (L654-L662) hands a detached copy of the message to the share screen, because the stored one may be gone while the screen is open. It works the same from the chat and from the shared items (the shared items are opened with the account of the room since feat(chat): Add a counter, a menu and actions to the media viewer #2772).
  • Share screen: ShareViewController(toForwardFile:fromChatViewController:) (ShareViewController.m#L61-L66, .h#L30) and the new type .fileShare of ShareConfirmationViewController (L73, shareFileMessage L494). The account is selected from the file message and its selector is hidden (ShareViewController.m#L274-L300, ShareViewController.m#L294).
  • Sending: sendFileShare (L828) shares the path from the message object in process (never from outside) with the existing shareFileOrFolder; it refuses a message of another account. The caption is shown on the confirmation screen and sent only when it was shown (forwardedCaption, L518).
  • Result in the viewer: shareViewControllerDidCancel closes the share screens (L735); after a successful share the viewer closes and posts NCChatViewControllerForwardNotification so the chat opens the target conversation, as the chat does for its forwards (L746-L760).
  • No new strings: "Forward" exists in Localizable.strings.

Test

  • UnitNCMediaViewerForwardTest: a file of the own account can be forwarded; not a file without a path, not a file of another account, not a deleted message, not a file of a federated room.

The account lookup in ShareViewController and the share screens and sending have no unit test: they live in UIKit controllers and shareFileOrFolder is a network call with no seam to run it without a server. Classified rooms are not covered by the test (the capability would have to be faked). Not tested on a device and not checked against a server.

CI: https://github.com/ToteMeiSter/talk-ios/actions/runs/39478124619 — Build and Test stable35 passed; 269 tests, 0 failures. The five UnitNCMediaViewerForwardTest cases passed.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Commit trailers:

Assisted-by: Claude-Code:claude-sonnet-5-5 (first three commits)
Assisted-by: Codex:gpt-6 (account-selection fix)
Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>

🤖 Generated with Claude Code

The conditions of the Reply and Delete entries of the message menu move
to NCChatMessage, so that other screens, like the media viewer, can ask
the same question instead of copying the rules.

Assisted-by: Claude-Code:claude-sonnet-5-5
Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
The media viewer shows "2 of 5" for the pictures and videos of the
conversation, with a "+" when older media can still be loaded. A menu
offers to save the shown media to Photos, to show all media of the
conversation, to show the message in the chat, to reply, to share and
to delete. Reply and delete use the same conditions as the message menu
of the chat, and a file of a group of files shared together deletes the
whole group, like the chat does. Only the chat that opened the viewer
allows reply and delete, the viewer opened from the shared items offers
neither and shows no counter. A picture can be drawn on from the toolbar,
a copy of the file is edited and sent to the conversation.

Saving needs NSPhotoLibraryAddUsageDescription.

Assisted-by: Claude-Code:claude-sonnet-5-5
Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
…versation

The media viewer gets a "Forward" button. It opens the conversation list
and shares the file of the message with the existing files sharing call,
so nothing is uploaded again. The path is read from the message object in
process. The account of the message is the one used, the account selector
is hidden and sending refuses a message of another account. The caption of
the file is shown on the confirmation screen and is only sent when shown.

Assisted-by: Claude-Code:claude-sonnet-5-5
Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Assisted-by: Claude-Code:claude-sonnet-5-5
Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
… share does

Assisted-by: Claude-Code:claude-sonnet-5-5
Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
Choose the account that owns the file before listing target conversations. The active account can differ from the message account.

Assisted-by: Codex:gpt-6

Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru>
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.

Media viewer: forward the shown file to another conversation

1 participant