diff --git a/flarum-notifiy-v2.js b/flarum-notifiy-v2.js
new file mode 100644
index 0000000..a11453d
--- /dev/null
+++ b/flarum-notifiy-v2.js
@@ -0,0 +1,135 @@
+(function () {
+ 'use strict';
+
+ var forumOrigin = window.location.origin;
+
+ function showTarget(targetValue) {
+ var targetUrl;
+ var forumLink;
+ var targetUrlLabel;
+ var postPanel;
+ var fallbackPanel;
+
+ if (!targetValue) {
+ return false;
+ }
+
+ try {
+ targetUrl = new URL(targetValue);
+
+ if (targetUrl.origin !== forumOrigin) {
+ console.warn(
+ 'Rejected forum target with unexpected origin:',
+ targetUrl.origin
+ );
+
+ return false;
+ }
+
+ if (targetUrl.pathname.indexOf('/d/') !== 0) {
+ console.warn(
+ 'Rejected forum target with unexpected path:',
+ targetUrl.pathname
+ );
+
+ return false;
+ }
+
+ forumLink = document.getElementById('forum-link');
+ targetUrlLabel = document.getElementById('target-url');
+ postPanel = document.getElementById('post-panel');
+ fallbackPanel = document.getElementById('fallback-panel');
+
+ if (
+ !forumLink ||
+ !targetUrlLabel ||
+ !postPanel ||
+ !fallbackPanel
+ ) {
+ console.warn(
+ 'Required landing-page elements were not found.'
+ );
+
+ return false;
+ }
+
+ forumLink.href = targetUrl.href;
+ targetUrlLabel.textContent = targetUrl.href;
+
+ postPanel.hidden = false;
+ fallbackPanel.hidden = true;
+
+ return true;
+ } catch (error) {
+ console.warn(
+ 'The forum target URL is invalid.',
+ error
+ );
+
+ return false;
+ }
+ }
+
+ async function initialize() {
+ var parameters;
+ var queryTarget;
+ var context;
+ var subPageId;
+
+ parameters = new URLSearchParams(
+ window.location.search
+ );
+
+ queryTarget = parameters.get('target');
+
+ /*
+ * Allow direct browser tests with ?target=...
+ */
+ if (showTarget(queryTarget)) {
+ return;
+ }
+
+ /*
+ * In Microsoft Teams the target is passed as subEntityId.
+ * TeamsJS v2 exposes that value as context.page.subPageId.
+ */
+ if (
+ !window.microsoftTeams ||
+ !window.microsoftTeams.app
+ ) {
+ console.info(
+ 'TeamsJS is unavailable; showing the notifications fallback.'
+ );
+
+ return;
+ }
+
+ try {
+ await window.microsoftTeams.app.initialize();
+
+ context =
+ await window.microsoftTeams.app.getContext();
+
+ subPageId =
+ context &&
+ context.page &&
+ context.page.subPageId
+ ? context.page.subPageId
+ : null;
+
+ console.info(
+ 'Teams page.subPageId:',
+ subPageId || '[none]'
+ );
+
+ showTarget(subPageId);
+ } catch (error) {
+ console.warn(
+ 'Could not read the Microsoft Teams context.',
+ error
+ );
+ }
+ }
+
+ initialize();
+})();
diff --git a/flarum-notify-v2.html b/flarum-notify-v2.html
new file mode 100644
index 0000000..d19c237
--- /dev/null
+++ b/flarum-notify-v2.html
@@ -0,0 +1,151 @@
+
+
+
+
+ sbp forum notifications
+
+
+
+
+
+
+
+
+
sbp forum
+
+
Forum activity notification
+
+
+ This Microsoft Teams app is a lightweight notifier.
+ It informs you about new activity in the sbp forum.
+
+
+
+
Open the related forum post:
+
Open forum post
+
+
+
+
+
+
+
+
+
+
+
+
+
+