Browse Source

Merge pull request #10593 from annando/matrix2

The Matrix and XMPP address is now transported via AP as well
pull/10594/head
Hypolite Petovan 1 year ago committed by GitHub
parent
commit
e146a5983c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      database.sql
  2. 2
      doc/database/db_apcontact.md
  3. 12
      src/Model/APContact.php
  4. 2
      src/Protocol/ActivityPub.php
  5. 11
      src/Protocol/ActivityPub/Transmitter.php
  6. 4
      static/dbstructure.config.php

4
database.sql

@ -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 '',

2
doc/database/db_apcontact.md

@ -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 | |

12
src/Model/APContact.php

@ -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');

2
src/Protocol/ActivityPub.php

@ -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'];

11
src/Protocol/ActivityPub/Transmitter.php

@ -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'];

4
static/dbstructure.config.php

@ -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" => ""],

Loading…
Cancel
Save