-
Notifications
You must be signed in to change notification settings - Fork 503
π Pinned messages - API #16239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
π Pinned messages - API #16239
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ebdb3ee
feat(pinned): Add basic API layout of pinned messages
nickvergessen bfd33aa
feat(pinned): Add response fields for last pinned and last dismissed ids
nickvergessen 3206065
fix(pinned): Return pinned messages when requesting the overview
nickvergessen 07a8931
fix(pinned): Implement actual pinning, hiding and unpinning API methods
nickvergessen 47c9525
test(pinned): Add integration tests for pinned messages
nickvergessen 30ef63d
feat(pinned): Add capability
nickvergessen 40e2a46
fix(pinned): Reset the hide-pinned-id when the same message is repinned
nickvergessen 00c3755
fix(pinned): Reset the last pinned id on unpinning
nickvergessen bf0f5f0
fix(pinned): Allow "Pin until"
nickvergessen 3e32fbb
feat(pinned): Expose pin actor and pinned until for messages
nickvergessen 8851d2b
fix(pinned): Handle message expiration
nickvergessen 4449271
chore(assets): Recompile assets
nickvergessen c331bdb
fix(pinned): Remove federation flag for now
nickvergessen e856d8e
fix(tests): Fix field name in tests
nickvergessen b483d2a
fix(pinned): Align exposed key with documented and tested one
nickvergessen 1918a39
test(pinned): Make test non-flaky
nickvergessen a341078
fix(pinned): At the timestamp when a message was pinned
nickvergessen 50a4eda
chore(assets): Recompile assets
nickvergessen f9ef8f7
fix(pinned): Fix sort order of pinned messages
nickvergessen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Talk\BackgroundJob; | ||
|
|
||
| use OCA\Talk\Chat\ChatManager; | ||
| use OCA\Talk\Exceptions\RoomNotFoundException; | ||
| use OCA\Talk\Manager; | ||
| use OCA\Talk\Model\Attachment; | ||
| use OCA\Talk\Service\AttachmentService; | ||
| use OCA\Talk\Service\RoomService; | ||
| use OCP\AppFramework\Utility\ITimeFactory; | ||
| use OCP\BackgroundJob\QueuedJob; | ||
| use OCP\Comments\NotFoundException; | ||
|
|
||
| class UnpinMessage extends QueuedJob { | ||
| public function __construct( | ||
| ITimeFactory $time, | ||
| protected Manager $manager, | ||
| protected ChatManager $chatManager, | ||
| protected AttachmentService $attachmentService, | ||
| protected RoomService $roomService, | ||
| ) { | ||
| parent::__construct($time); | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| #[\Override] | ||
| protected function run($argument): void { | ||
| $roomId = (int)$argument['roomId']; | ||
|
|
||
| try { | ||
| $room = $this->manager->getRoomById($roomId); | ||
| } catch (RoomNotFoundException) { | ||
| return; | ||
| } | ||
|
|
||
| $messageId = (int)$argument['messageId']; | ||
| try { | ||
| $comment = $this->chatManager->getComment($room, (string)$messageId); | ||
| } catch (NotFoundException) { | ||
| // Message most likely expired, reset the last_pinned_id if matching | ||
| if ($room->getLastPinnedId() === $messageId) { | ||
| $newLastPinned = 0; | ||
| $attachments = $this->attachmentService->getAttachmentsByType($room, Attachment::TYPE_PINNED, 0, 1); | ||
| if (isset($attachments[0])) { | ||
| $newLastPinned = $attachments[0]->getMessageId(); | ||
| } | ||
| $this->roomService->setLastPinnedId($room, $newLastPinned); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| $this->chatManager->unpinMessage($room, $comment, null); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, that only works for messages that have a unpin set, i.e. have a unpin job. I would have expected it to be in https://github.com/nextcloud/spreed/blob/main/lib/BackgroundJob/ExpireChatMessages.php, but I see that it's a db operation there. So we might end up in a situation were it's set on room, but still expired?
Also, just to mention it, this code part is identical to the chatmanager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which will be the case going forward. At the moment of pinning I will set pinUntil when the message expires at some point
Yeah just renamed variablesβ¦