about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-06-06 20:07:54 +0000
committerZach DeCook <zachdecook@librem.one>2022-06-06 20:07:54 +0000
commit385004df10d706fca1323763e84da6fd11968603 (patch)
tree8f6c2de1438bba269c7b1d16a9e20c59e2b7f208
parentdd106c063b84060dd158cd5d3b79f4ac3a15eecc (diff)
downloadphp-xmpp-invitation-385004df10d706fca1323763e84da6fd11968603.tar.gz
URIs: Add Contact Invitation with IBR
-rw-r--r--README.md1
-rw-r--r--index.php4
-rw-r--r--lang/en.json6
3 files changed, 10 insertions, 1 deletions
diff --git a/README.md b/README.md
index 7213759..18af9ee 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@ For the JID romeo@xmpp.example, it will create the following page ([live example
 * [xmpp:name@muc.example.com?join](https://zachdecook.com/chat?xmpp:name@muc.example.com?join)
 * Registration with pre-defined account name ([XEP-0445](https://xmpp.org/extensions/xep-0445.html#sect-idm46085194296336)):  [xmpp:juliet@example.com?register;preauth=TOKEN](https://zachdecook.com/chat?xmpp:juliet@example.com?register;preauth=TOKEN)
 * Registration on a server ([XEP-0445](https://xmpp.org/extensions/xep-0445.html#sect-idm46085194293584)):  [xmpp:example.com?register;preauth=TOKEN](https://zachdecook.com/chat?xmpp:example.com?register;preauth=TOKEN)
+* Contact Invitation with IBR ([XEP-0445](https://xmpp.org/extensions/xep-0445.html#sect-idm46085194290992)) [xmpp:romeo@example.com?roster;preauth=TOKEN;ibr=y](https://zachdecook.com/chat?xmpp:romeo@example.com?roster;preauth=TOKEN;ibr=y)
 
 
 ## Design decisions
diff --git a/index.php b/index.php
index 6b37a18..a8d9195 100644
--- a/index.php
+++ b/index.php
@@ -19,6 +19,7 @@
 		$uri = "xmpp:" . $uri;
 	}
 	// TODO: Better invitation type detection.
+	$parsed = parse_url($uri);
 	$action = $lang->chat;
 	if ( str_contains($uri, '?join') ) {
 		$action = $lang->muc;
@@ -27,8 +28,9 @@
 		if ( str_contains($uri, "@") ) {
 			$action = $lang->register_name;
 		}
+	} elseif ( str_contains($parsed['query'], 'ibr=y') ) {
+		$action = $lang->ibr;
 	}
-	$parsed = parse_url($uri);
 	$name = explode("@", $parsed['path'])[0];
 	$server = explode("@", $parsed['path'])[1] ?? $name;
 	function t($template) {
diff --git a/lang/en.json b/lang/en.json
index e5e0677..7747caf 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -23,6 +23,12 @@
     "button": "Register as {{name}}@{{server}}",
     "":""
   },
+  "ibr": {
+    "title": "Invitation from {{Name}}",
+    "heading": "{{Name}} has invited you to chat",
+    "button": "Chat with {{Name}} on {{server}}",
+    "":""
+  },
   "clients": "You need to install an XMPP client to access the XMPP network.",
   "recommend": "Here are the most commonly used clients for {{os}}:",
   "checkfulllist": "See the <a href='https://xmpp.org/software/clients/'>full list</a> of XMPP clients for other platforms and devices.",