~earboxer/php-xmpp-invitation

385004df10d706fca1323763e84da6fd11968603 — Zach DeCook 2 years ago dd106c0
URIs: Add Contact Invitation with IBR
3 files changed, 10 insertions(+), 1 deletions(-)

M README.md
M index.php
M lang/en.json
M README.md => README.md +1 -0
@@ 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

M index.php => index.php +3 -1
@@ 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) {

M lang/en.json => lang/en.json +6 -0
@@ 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.",