]> git.mxchange.org Git - friendica.git/commitdiff
The Matrix and XMPP address is now transported via AP as well
authorMichael <heluecht@pirati.ca>
Tue, 10 Aug 2021 23:49:09 +0000 (23:49 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 10 Aug 2021 23:49:09 +0000 (23:49 +0000)
database.sql
doc/database/db_apcontact.md
src/Model/APContact.php
src/Protocol/ActivityPub.php
src/Protocol/ActivityPub/Transmitter.php
static/dbstructure.config.php

index 3c2feb59f1c8c5ef25bc414382c38ce312404085..4d444cbe50ddcd97d7c6d03eb0316f1a792baca9 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 2021.09-dev (Siberian Iris)
--- DB_UPDATE_VERSION 1432
+-- DB_UPDATE_VERSION 1433
 -- ------------------------------------------
 
 
@@ -332,6 +332,8 @@ CREATE TABLE IF NOT EXISTS `apcontact` (
        `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '',
        `name` varchar(255) COMMENT '',
        `about` text COMMENT '',
+       `xmpp` varchar(255) COMMENT 'XMPP address',
+       `matrix` varchar(255) COMMENT 'Matrix address',
        `photo` varchar(255) COMMENT '',
        `header` varchar(255) COMMENT 'Header picture',
        `addr` varchar(255) COMMENT '',
index 5abf60f10f5a06b49c40cf8022250fbb8a0e886e..ee95d994f9b018407053334837a85ae5b55f169f 100644 (file)
@@ -22,6 +22,8 @@ Fields
 | nick             |                                                                     | varchar(255)   | NO   |     |                     |       |
 | name             |                                                                     | varchar(255)   | YES  |     | NULL                |       |
 | about            |                                                                     | text           | YES  |     | NULL                |       |
+| xmpp             | XMPP address                                                        | varchar(255)   | YES  |     | NULL                |       |
+| matrix           | Matrix address                                                      | varchar(255)   | YES  |     | NULL                |       |
 | photo            |                                                                     | varchar(255)   | YES  |     | NULL                |       |
 | header           | Header picture                                                      | varchar(255)   | YES  |     | NULL                |       |
 | addr             |                                                                     | varchar(255)   | YES  |     | NULL                |       |
index d0a0d0d3f6b7eb4eea5045a5f9ddc7ca4f7544eb..13add7e658939fdd92b9d6871eaf537aebe86c4b 100644 (file)
@@ -239,6 +239,18 @@ class APContact
 
                $apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary', '@value'));
 
+               $ims = JsonLD::fetchElementArray($compacted, 'vcard:hasInstantMessage');
+               if (!empty($ims)) {
+                       foreach ($ims as $link) {
+                               if (substr($link, 0, 5) == 'xmpp:') {
+                                       $apcontact['xmpp'] = substr($link, 5);
+                               }
+                               if (substr($link, 0, 7) == 'matrix:') {
+                                       $apcontact['matrix'] = substr($link, 7);
+                               }
+                       }
+               }
+
                $apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
                if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
                        $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
index 0f62ab5376ca192f9cb9ad59ab4f9a74703a1b5c..153ee54658fde831ce13aa96f9090971d4ff6dad 100644 (file)
@@ -157,6 +157,8 @@ class ActivityPub
                // $profile['keywords']
                // $profile['location']
                $profile['about'] = $apcontact['about'];
+               $profile['xmpp'] = $apcontact['xmpp'];
+               $profile['matrix'] = $apcontact['matrix'];
                $profile['batch'] = $apcontact['sharedinbox'];
                $profile['notify'] = $apcontact['inbox'];
                $profile['poll'] = $apcontact['outbox'];
index 2ca40259d5095527a0bf6831e7ecc61b0762598f..ab23f81d84da03c77bb6e4676c3ad8df9b1562eb 100644 (file)
@@ -352,6 +352,17 @@ class Transmitter
                        $data['summary'] = BBCode::convertForUriId($owner['uri-id'] ?? 0, $owner['about'], BBCode::EXTERNAL);
                }
 
+               if (!empty($owner['xmpp']) || !empty($owner['matrix'])) {
+                       $data['vcard:hasInstantMessage'] = [];
+
+                       if (!empty($owner['xmpp'])) {
+                               $data['vcard:hasInstantMessage'][] = 'xmpp:' . $owner['xmpp'];
+                       }
+                       if (!empty($owner['matrix'])) {
+                               $data['vcard:hasInstantMessage'][] = 'matrix:' . $owner['matrix'];
+                       }
+               }
+
                $data['url'] = $owner['url'];
                $data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
                $data['discoverable'] = (bool)$owner['net-publish'];
index 23b64860c3212fc83ac0c712d95847602c52e121..f820401a192939350fd3144f34e5567be0f48ff0 100644 (file)
@@ -55,7 +55,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1432);
+       define('DB_UPDATE_VERSION', 1433);
 }
 
 return [
@@ -392,6 +392,8 @@ return [
                        "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
                        "name" => ["type" => "varchar(255)", "comment" => ""],
                        "about" => ["type" => "text", "comment" => ""],
+                       "xmpp" => ["type" => "varchar(255)", "comment" => "XMPP address"],
+                       "matrix" => ["type" => "varchar(255)", "comment" => "Matrix address"],
                        "photo" => ["type" => "varchar(255)", "comment" => ""],
                        "header" => ["type" => "varchar(255)", "comment" => "Header picture"],
                        "addr" => ["type" => "varchar(255)", "comment" => ""],