diff --git a/src/Support/NotificationPayloadFactory.php b/src/Support/NotificationPayloadFactory.php index f3e883a..c64f5a9 100644 --- a/src/Support/NotificationPayloadFactory.php +++ b/src/Support/NotificationPayloadFactory.php @@ -19,35 +19,39 @@ class NotificationPayloadFactory /** * Build the payload for Microsoft Teams Activity Feed. * - * Informational only (systemDefault). - * No clickable navigation from the Activity Feed is expected. + * Informational notification that opens the Teams app side pane + * and marks the activity item as read. * * @return array */ public function make(User $recipient, BlueprintInterface $blueprint): array { - // Activity Feed is informational only + // Activity Feed type (informational, but clickable via /l/entity) $activityType = 'systemDefault'; - $forumName = trim((string) $this->settings->get('forum_title', 'Flarum')) ?: 'Flarum'; + $forumName = trim((string) $this->settings->get('forum_title', 'sbp forum')) ?: 'sbp forum'; // Resolve dynamic data $discussionTitle = $this->resolveDiscussionTitle($blueprint) ?? $forumName; - $discussionUrl = $this->resolveSubjectUrl($blueprint) - ?? rtrim((string) $this->settings->get('sbp-jm-msteams-webhook.forum_base_url', ''), '/'); - $previewSnippet = $this->buildPreviewText($blueprint); $reasonText = $this->buildReasonTextEn($blueprint); - // Teams requires /l/ URLs for topic.source = text - // /l/browser is the official, neutral deep link for external pages - $teamsBrowserLink = 'https://teams.microsoft.com/l/browser/' . rawurlencode($discussionUrl); + // Teams App + Personal Tab (THIS is what makes it clickable & read) + $teamsAppId = 'd92b1be6-ea92-46b1-bcb0-c08ffdd1a61a'; + $teamsEntityId = '8ffe419f-ca44-4627-a4b2-f223da2d07aa'; + + // Opens the app side pane and marks the activity as read + $teamsTabLink = sprintf( + 'https://teams.microsoft.com/l/entity/%s/%s', + $teamsAppId, + $teamsEntityId + ); return [ 'topic' => [ 'source' => 'text', 'value' => $discussionTitle, - 'webUrl' => $teamsBrowserLink, + 'webUrl' => $teamsTabLink, ], 'activityType' => $activityType, 'previewText' => [ @@ -82,6 +86,7 @@ class NotificationPayloadFactory /** * Resolve the URL to the discussion or specific post. + * (Not used for navigation in Teams, but kept for completeness.) */ protected function resolveSubjectUrl(BlueprintInterface $blueprint): ?string { @@ -113,7 +118,7 @@ class NotificationPayloadFactory } /** - * English reason text for Activity Feed (systemDefault). + * English reason text for Activity Feed. */ protected function buildReasonTextEn(BlueprintInterface $blueprint): string { @@ -166,4 +171,4 @@ class NotificationPayloadFactory return mb_substr($text, 0, 150); } -} +} \ No newline at end of file