jetzt funktioniert der notifier!

This commit is contained in:
Jörg Mühlberger 2026-07-21 18:26:17 +02:00
parent 67a735654a
commit 6348140c37
1 changed files with 52 additions and 19 deletions

View File

@ -37,8 +37,14 @@ class NotificationPayloadFactory
$previewSnippet = $this->buildPreviewText($blueprint); $previewSnippet = $this->buildPreviewText($blueprint);
$reasonText = $this->buildReasonTextEn($blueprint); $reasonText = $this->buildReasonTextEn($blueprint);
$landingPageUrl = $this->buildLandingPageUrl($blueprint); $landingPageUrl = $this->buildLandingPageUrl($blueprint);
$teamsTabLink = $this->buildTeamsTabLink($landingPageUrl); $subjectUrl = $this->resolveSubjectUrl($blueprint);
$teamsTabLink = $this->buildTeamsTabLink(
$landingPageUrl,
$subjectUrl
);
return [ return [
'topic' => [ 'topic' => [
@ -91,25 +97,53 @@ class NotificationPayloadFactory
/** /**
* Build a Teams deep link to the personal app tab. * Build a Teams deep link to the personal app tab.
*/ */
protected function buildTeamsTabLink(string $webUrl): string /**
{ * Build a Teams deep link to the personal app tab.
$teamsAppId = trim((string) $this->settings->get( *
* The static landing page is supplied as webUrl. The exact Flarum
* discussion or post URL is passed as subEntityId and is exposed by
* TeamsJS v2 as context.page.subPageId.
*/
protected function buildTeamsTabLink(
string $webUrl,
?string $subjectUrl
): string {
$teamsAppId = trim(
(string) $this->settings->get(
'sbp-jm-msteams-webhook.teams_app_id', 'sbp-jm-msteams-webhook.teams_app_id',
self::DEFAULT_TEAMS_APP_ID self::DEFAULT_TEAMS_APP_ID
)); )
);
if ($teamsAppId === '') { if ($teamsAppId === '') {
$teamsAppId = self::DEFAULT_TEAMS_APP_ID; $teamsAppId = self::DEFAULT_TEAMS_APP_ID;
} }
return sprintf( $query = [
'https://teams.microsoft.com/l/entity/%s/%s?webUrl=%s', 'webUrl' => $webUrl,
rawurlencode($teamsAppId), ];
rawurlencode(self::TEAMS_ENTITY_ID),
rawurlencode($webUrl) if ($subjectUrl !== null) {
$query['context'] = json_encode(
[
'subEntityId' => $subjectUrl,
],
JSON_UNESCAPED_SLASHES
| JSON_THROW_ON_ERROR
);
}
return sprintf(
'https://teams.microsoft.com/l/entity/%s/%s?%s',
rawurlencode($teamsAppId),
rawurlencode(self::TEAMS_ENTITY_ID),
http_build_query(
$query,
'',
'&',
PHP_QUERY_RFC3986
)
); );
} }
/** /**
* Resolve and validate the configured public forum base URL. * Resolve and validate the configured public forum base URL.
*/ */
@ -157,7 +191,6 @@ class NotificationPayloadFactory
return null; return null;
} }
/** /**
* Resolve the URL to the discussion or exact post. * Resolve the URL to the discussion or exact post.
*/ */