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); } }