]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #5794 from annando/ap1
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 2 Oct 2018 15:24:04 +0000 (11:24 -0400)
committerGitHub <noreply@github.com>
Tue, 2 Oct 2018 15:24:04 +0000 (11:24 -0400)
ActivityPub support

54 files changed:
boot.php
composer.json
composer.lock
config/dbstructure.json
include/api.php
include/conversation.php
index.php
mod/admin.php
mod/contacts.php
mod/dfrn_confirm.php
mod/dirfind.php
mod/display.php
mod/item.php
mod/photos.php
mod/poke.php
mod/profile.php
mod/subthread.php
mod/tagger.php
mod/xrd.php
src/BaseModule.php
src/Content/ContactSelector.php
src/Content/Widget.php
src/Core/System.php
src/Model/APContact.php [new file with mode: 0644]
src/Model/Contact.php
src/Model/Conversation.php
src/Model/Event.php
src/Model/Item.php
src/Model/Mail.php
src/Model/Profile.php
src/Model/Term.php
src/Model/User.php
src/Module/Followers.php [new file with mode: 0644]
src/Module/Following.php [new file with mode: 0644]
src/Module/Inbox.php [new file with mode: 0644]
src/Module/Magic.php
src/Module/Object.php [new file with mode: 0644]
src/Module/Outbox.php [new file with mode: 0644]
src/Module/Owa.php
src/Network/Probe.php
src/Object/Post.php
src/Protocol/ActivityPub.php [new file with mode: 0644]
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Protocol/PortableContact.php
src/Util/HTTPSignature.php
src/Util/JsonLD.php [new file with mode: 0644]
src/Util/LDSignature.php [new file with mode: 0644]
src/Worker/APDelivery.php [new file with mode: 0644]
src/Worker/Delivery.php
src/Worker/Notifier.php
src/Worker/ProfileUpdate.php
src/Worker/UpdateGContact.php
util/messages.po

index 581bbb1817ae15a4df8ec1695faf222befd18f79..b5c9166982226830dbcab7a52bde85e92cd96af9 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM',     'Friendica');
 define('FRIENDICA_CODENAME',     'The Tazmans Flax-lily');
 define('FRIENDICA_VERSION',      '2018.12-dev');
 define('DFRN_PROTOCOL_VERSION',  '2.23');
-define('DB_UPDATE_VERSION',      1283);
+define('DB_UPDATE_VERSION',      1284);
 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
 
 /**
index c717775506f74ca26e145e6f8332d77c03195963..68e5cae99bc94292d79f09d642b2c3c0c65989af 100644 (file)
                "npm-asset/jgrowl": "^1.4",
                "npm-asset/fullcalendar": "^3.0.1",
                "npm-asset/cropperjs": "1.2.2",
-               "npm-asset/imagesloaded": "4.1.4"
+               "npm-asset/imagesloaded": "4.1.4",
+               "friendica/json-ld": "^1.0"
        },
        "repositories": [
                {
                        "type": "vcs",
-                       "url": "https://github.com/pear/Text_Highlighter"
+                       "url": "https://git.friendi.ca/friendica/php-json-ld"
                }
        ],
        "autoload": {
index b0ff745c681f2eaf75187c29fdda973dc68959ad..f163101481feae2478d7658811c40c142623e305 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "5f6a43237dc52758484cd21cd76e8ce6",
+    "content-hash": "ece71ff50417ed5fcc1a439ea554925c",
     "packages": [
         {
             "name": "asika/simple-console",
             ],
             "time": "2015-08-05T01:03:42+00:00"
         },
+        {
+            "name": "friendica/json-ld",
+            "version": "1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://git.friendi.ca/friendica/php-json-ld",
+                "reference": "a9ac64daf01cfd97e80c36a5104247d37c0ae5ef"
+            },
+            "require": {
+                "ext-json": "*",
+                "php": ">=5.4.0"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "jsonld.php"
+                ]
+            },
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Digital Bazaar, Inc.",
+                    "email": "support@digitalbazaar.com",
+                    "url": "http://digitalbazaar.com/"
+                },
+                {
+                    "name": "Friendica Team",
+                    "url": "https://friendi.ca/"
+                }
+            ],
+            "description": "A JSON-LD Processor and API implementation in PHP.",
+            "homepage": "https://git.friendi.ca/friendica/php-json-ld",
+            "keywords": [
+                "JSON",
+                "JSON-LD",
+                "Linked Data",
+                "RDF",
+                "Semantic Web",
+                "jsonld"
+            ],
+            "time": "2018-09-28T00:01:12+00:00"
+        },
         {
             "name": "fxp/composer-asset-plugin",
             "version": "v1.4.2",
         }
     ],
     "packages-dev": [
+        {
+            "name": "digitalbazaar/json-ld",
+            "version": "0.4.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/digitalbazaar/php-json-ld.git",
+                "reference": "dc1bd23f0ee2efd27ccf636d32d2738dabcee182"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/digitalbazaar/php-json-ld/zipball/dc1bd23f0ee2efd27ccf636d32d2738dabcee182",
+                "reference": "dc1bd23f0ee2efd27ccf636d32d2738dabcee182",
+                "shasum": ""
+            },
+            "require": {
+                "ext-json": "*",
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "autoload": {
+                "files": [
+                    "jsonld.php"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Digital Bazaar, Inc.",
+                    "email": "support@digitalbazaar.com"
+                }
+            ],
+            "description": "A JSON-LD Processor and API implementation in PHP.",
+            "homepage": "https://github.com/digitalbazaar/php-json-ld",
+            "keywords": [
+                "JSON-LD",
+                "Linked Data",
+                "RDF",
+                "Semantic Web",
+                "json",
+                "jsonld"
+            ],
+            "time": "2016-04-25T04:17:52+00:00"
+        },
         {
             "name": "doctrine/instantiator",
             "version": "1.0.5",
index c467ba6bc7644a062c896289a806362b584df9ac..8f676861569d3fd89e67c8b851fc31b28227d26c 100644 (file)
                        "name": ["UNIQUE", "name"]
                }
        },
+       "apcontact": {
+               "comment": "ActivityPub compatible contacts - used in the ActivityPub implementation",
+               "fields": {
+                       "url": {"type": "varbinary(255)", "not null": "1", "primary": "1", "comment": "URL of the contact"},
+                       "uuid": {"type": "varchar(255)", "comment": ""},
+                       "type": {"type": "varchar(20)", "not null": "1", "comment": ""},
+                       "following": {"type": "varchar(255)", "comment": ""},
+                       "followers": {"type": "varchar(255)", "comment": ""},
+                       "inbox": {"type": "varchar(255)", "not null": "1", "comment": ""},
+                       "outbox": {"type": "varchar(255)", "comment": ""},
+                       "sharedinbox": {"type": "varchar(255)", "comment": ""},
+                       "nick": {"type": "varchar(255)", "not null": "1", "default": "", "comment": ""},
+                       "name": {"type": "varchar(255)", "comment": ""},
+                       "about": {"type": "text", "comment": ""},
+                       "photo": {"type": "varchar(255)", "comment": ""},
+                       "addr": {"type": "varchar(255)", "comment": ""},
+                       "alias": {"type": "varchar(255)", "comment": ""},
+                       "pubkey": {"type": "text", "comment": ""},
+                       "baseurl": {"type": "varchar(255)", "comment": "baseurl of the ap contact"},
+                       "updated": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": ""}
+
+               },
+               "indexes": {
+                       "PRIMARY": ["url"],
+                       "addr": ["addr(32)"],
+                       "url": ["followers(190)"]
+               }
+       },
        "attach": {
                "comment": "file attachments",
                "fields": {
                        "reply-to-uri": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "URI to which this item is a reply"},
                        "conversation-uri": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "GNU Social conversation URI"},
                        "conversation-href": {"type": "varbinary(255)", "not null": "1", "default": "", "comment": "GNU Social conversation link"},
-                       "protocol": {"type": "tinyint unsigned", "not null": "1", "default": "0", "comment": "The protocol of the item"},
+                       "protocol": {"type": "tinyint unsigned", "not null": "1", "default": "255", "comment": "The protocol of the item"},
                        "source": {"type": "mediumtext", "comment": "Original source"},
                        "received": {"type": "datetime", "not null": "1", "default": "0001-01-01 00:00:00", "comment": "Receiving date"}
                },
index 4cc1753c79a35c5dc0c38e8bc7da306a59c55e3f..004388ac467da187007888e9971deef9470df042 100644 (file)
@@ -4612,7 +4612,7 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
        $owner_record = DBA::selectFirst('contact', [], ['uid' => api_user(), 'self' => true]);
 
        $arr = [];
-       $arr['guid']          = System::createGUID(32);
+       $arr['guid']          = System::createUUID();
        $arr['uid']           = intval(api_user());
        $arr['uri']           = $uri;
        $arr['parent-uri']    = $uri;
index 59ee5ed8248cbdd4b2b7be65c74c6b3382bc2182..1185e9dc3b372193db2529451ec1e76f28e93b4d 100644 (file)
@@ -556,7 +556,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o
                if (in_array($mode, ['community', 'contacts'])) {
                        $writable = true;
                } else {
-                       $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
+                       $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
                }
 
                if (!local_user()) {
@@ -807,7 +807,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
 
        foreach ($items as $index => $item) {
                if ($item['uid'] == 0) {
-                       $items[$index]['writable'] = in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
+                       $items[$index]['writable'] = in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
                }
        }
 
@@ -877,7 +877,7 @@ function item_photo_menu($item) {
                }
 
                if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
-                       in_array($item['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
+                       in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
                        $menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
                }
        } else {
index 184a195924cc8acb715dc2f7654dfb8301b847b2..bccdebe7b05f65ab9f0999343d7355b4382bfc7a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -332,15 +332,21 @@ if ($a->module_loaded) {
        $a->page['page_title'] = $a->module;
        $placeholder = '';
 
+       Addon::callHooks($a->module . '_mod_init', $placeholder);
+
        if ($a->module_class) {
-               Addon::callHooks($a->module . '_mod_init', $placeholder);
                call_user_func([$a->module_class, 'init']);
        } else if (function_exists($a->module . '_init')) {
-               Addon::callHooks($a->module . '_mod_init', $placeholder);
                $func = $a->module . '_init';
                $func($a);
        }
 
+       // "rawContent" is especially meant for technical endpoints.
+       // This endpoint doesn't need any theme initialization or other comparable stuff.
+       if (!$a->error && $a->module_class) {
+               call_user_func([$a->module_class, 'rawContent']);
+       }
+
        if (function_exists(str_replace('-', '_', $a->getCurrentTheme()) . '_init')) {
                $func = str_replace('-', '_', $a->getCurrentTheme()) . '_init';
                $func($a);
index 562845ecc80b69851f9c70ff52d6fccea4f1ed69..77ac7eddf8ccf135a0cf6d37c3a0eead0a0f6998 100644 (file)
@@ -1488,7 +1488,7 @@ function admin_page_site(App $a)
                '$community_page_style' => ['community_page_style', L10n::t("Community pages for visitors"), Config::get('system','community_page_style'), L10n::t("Which community pages should be available for visitors. Local users always see both pages."), $community_page_style_choices],
                '$max_author_posts_community_page' => ['max_author_posts_community_page', L10n::t("Posts per user on community page"), Config::get('system','max_author_posts_community_page'), L10n::t("The maximum number of posts per user on the community page. \x28Not valid for 'Global Community'\x29")],
                '$ostatus_disabled'     => ['ostatus_disabled', L10n::t("Enable OStatus support"), !Config::get('system','ostatus_disabled'), L10n::t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")],
-               '$ostatus_full_threads' => ['ostatus_full_threads', L10n::t("Only import OStatus threads from our contacts"), Config::get('system','ostatus_full_threads'), L10n::t("Normally we import every content from our OStatus contacts. With this option we only store threads that are started by a contact that is known on our system.")],
+               '$ostatus_full_threads' => ['ostatus_full_threads', L10n::t("Only import OStatus/ActivityPub threads from our contacts"), Config::get('system','ostatus_full_threads'), L10n::t("Normally we import every content from our OStatus and ActivityPub contacts. With this option we only store threads that are started by a contact that is known on our system.")],
                '$ostatus_not_able'     => L10n::t("OStatus support can only be enabled if threading is enabled."),
                '$diaspora_able'        => $diaspora_able,
                '$diaspora_not_able'    => L10n::t("Diaspora support can't be enabled because Friendica was installed into a sub directory."),
index 68dbbd59ddbb4e904ed5b57f087c9751be8a177b..298c314b299fbce234f1d962cb04c3f24336b29d 100644 (file)
@@ -533,7 +533,7 @@ function contacts_content(App $a, $update = 0)
                        $relation_text = '';
                }
 
-               if (!in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
+               if (!in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])) {
                        $relation_text = "";
                }
 
@@ -555,7 +555,7 @@ function contacts_content(App $a, $update = 0)
                }
                $lblsuggest = (($contact['network'] === Protocol::DFRN) ? L10n::t('Suggest friends') : '');
 
-               $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
+               $poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
 
                $nettype = L10n::t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
 
@@ -966,7 +966,7 @@ function contact_conversations(App $a, $contact_id, $update)
                $profiledata = Contact::getDetailsByURL($contact["url"]);
 
                if (local_user()) {
-                       if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+                       if (in_array($profiledata["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                                $profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
                        }
                }
@@ -990,7 +990,7 @@ function contact_posts(App $a, $contact_id)
                $profiledata = Contact::getDetailsByURL($contact["url"]);
 
                if (local_user()) {
-                       if (in_array($profiledata["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+                       if (in_array($profiledata["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                                $profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
                        }
                }
@@ -1071,7 +1071,7 @@ function _contact_detail_for_template(array $rr)
  */
 function contact_actions($contact)
 {
-       $poll_enabled = in_array($contact['network'], [Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
+       $poll_enabled = in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::FEED, Protocol::MAIL]);
        $contact_actions = [];
 
        // Provide friend suggestion only for Friendica contacts
index 41b5e0ef54f16587dae6e2935ad40916b801e519..90d3d8990c87873658bd81d077015ba855871072 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Model\Group;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Protocol\Diaspora;
+use Friendica\Protocol\ActivityPub;
 use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -335,10 +336,17 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                                intval($contact_id)
                        );
                } else {
+                       if ($network == Protocol::ACTIVITYPUB) {
+                               ActivityPub::transmitContactAccept($contact['url'], $contact['hub-verify'], $uid);
+                               $pending = true;
+                       } else {
+                               $pending = false;
+                       }
+
                        // $network !== Protocol::DFRN
                        $network = defaults($contact, 'network', Protocol::OSTATUS);
 
-                       $arr = Probe::uri($contact['url']);
+                       $arr = Probe::uri($contact['url'], $network);
 
                        $notify  = defaults($contact, 'notify' , $arr['notify']);
                        $poll    = defaults($contact, 'poll'   , $arr['poll']);
@@ -348,7 +356,7 @@ function dfrn_confirm_post(App $a, $handsfree = null)
                        $new_relation = $contact['rel'];
                        $writable = $contact['writable'];
 
-                       if ($network === Protocol::DIASPORA) {
+                       if (in_array($network, [Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
                                if ($duplex) {
                                        $new_relation = Contact::FRIEND;
                                } else {
@@ -362,30 +370,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                        DBA::delete('intro', ['id' => $intro_id]);
 
-                       $r = q("UPDATE `contact` SET `name-date` = '%s',
-                               `uri-date` = '%s',
-                               `addr` = '%s',
-                               `notify` = '%s',
-                               `poll` = '%s',
-                               `blocked` = 0,
-                               `pending` = 0,
-                               `network` = '%s',
-                               `writable` = %d,
-                               `hidden` = %d,
-                               `rel` = %d
-                               WHERE `id` = %d
-                       ",
-                               DBA::escape(DateTimeFormat::utcNow()),
-                               DBA::escape(DateTimeFormat::utcNow()),
-                               DBA::escape($addr),
-                               DBA::escape($notify),
-                               DBA::escape($poll),
-                               DBA::escape($network),
-                               intval($writable),
-                               intval($hidden),
-                               intval($new_relation),
-                               intval($contact_id)
-                       );
+                       $fields = ['name-date' => DateTimeFormat::utcNow(),
+                               'uri-date' => DateTimeFormat::utcNow(), 'addr' => $addr,
+                               'notify' => $notify, 'poll' => $poll, 'blocked' => false,
+                               'pending' => $pending, 'network' => $network,
+                               'writable' => $writable, 'hidden' => $hidden, 'rel' => $new_relation];
+                       DBA::update('contact', $fields, ['id' => $contact_id]);
                }
 
                if (!DBA::isResult($r)) {
@@ -403,6 +393,10 @@ function dfrn_confirm_post(App $a, $handsfree = null)
 
                Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
 
+               if ($network == Protocol::ACTIVITYPUB && $duplex) {
+                       ActivityPub::transmitActivity('Follow', $contact['url'], $uid);
+               }
+
                // Let's send our user to the contact editor in case they want to
                // do anything special with this new friend.
                if ($handsfree === null) {
index 332fe90f6c48cf5af9b0a170fb8e6783b2b2581a..4223bb6ecd34bb3e196f9c1a62acbee7ab536810 100644 (file)
@@ -54,7 +54,7 @@ function dirfind_content(App $a, $prefix = "") {
                if ((valid_email($search) && Network::isEmailDomainValid($search)) ||
                        (substr(normalise_link($search), 0, 7) == "http://")) {
                        $user_data = Probe::uri($search);
-                       $discover_user = (in_array($user_data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
+                       $discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
                }
        }
 
index 907bf8ebba50d16b54ff34e341fe56c9e3da9408..25bda99d013881eeacd20ecf08a1f4e3ddefa3f4 100644 (file)
@@ -17,6 +17,7 @@ use Friendica\Model\Group;
 use Friendica\Model\Item;
 use Friendica\Model\Profile;
 use Friendica\Protocol\DFRN;
+use Friendica\Protocol\ActivityPub;
 
 function display_init(App $a)
 {
@@ -43,7 +44,7 @@ function display_init(App $a)
 
        $item = null;
 
-       $fields = ['id', 'parent', 'author-id', 'body', 'uid'];
+       $fields = ['id', 'parent', 'author-id', 'body', 'uid', 'guid'];
 
        // If there is only one parameter, then check if this parameter could be a guid
        if ($a->argc == 2) {
@@ -76,6 +77,10 @@ function display_init(App $a)
                displayShowFeed($item["id"], false);
        }
 
+       if (ActivityPub::isRequest()) {
+               goaway(str_replace('display/', 'object/', $a->query_string));
+       }
+
        if ($item["id"] != $item["parent"]) {
                $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $item["parent"]]);
        }
index 213a9907898bf0cafa98de592528716c2018bd23..5a0658b0209fbf5bf5fd1cb038da0cbc6ac89169 100644 (file)
@@ -159,7 +159,7 @@ function item_post(App $a) {
        }
 
        // Allow commenting if it is an answer to a public post
-       $allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
+       $allow_comment = local_user() && ($profile_uid == 0) && $parent && in_array($parent_item['network'], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN]);
 
        // Now check that valid personal details have been provided
        if (!can_write_wall($profile_uid) && !$allow_comment) {
@@ -240,7 +240,7 @@ function item_post(App $a) {
                $emailcc           =      notags(trim(defaults($_REQUEST, 'emailcc' , '')));
                $body              = escape_tags(trim(defaults($_REQUEST, 'body'    , '')));
                $network           =      notags(trim(defaults($_REQUEST, 'network' , Protocol::DFRN)));
-               $guid              =      System::createGUID(32);
+               $guid              =      System::createUUID();
 
                $postopts = defaults($_REQUEST, 'postopts', '');
 
@@ -343,20 +343,11 @@ function item_post(App $a) {
 
        $tags = get_tags($body);
 
-       // Add a tag if the parent contact is from OStatus (This will notify them during delivery)
-       if ($parent) {
-               if ($thr_parent_contact['network'] == Protocol::OSTATUS) {
-                       $contact = '@[url=' . $thr_parent_contact['url'] . ']' . $thr_parent_contact['nick'] . '[/url]';
-                       if (!stripos(implode($tags), '[url=' . $thr_parent_contact['url'] . ']')) {
-                               $tags[] = $contact;
-                       }
-               }
-
-               if ($parent_contact['network'] == Protocol::OSTATUS) {
-                       $contact = '@[url=' . $parent_contact['url'] . ']' . $parent_contact['nick'] . '[/url]';
-                       if (!stripos(implode($tags), '[url=' . $parent_contact['url'] . ']')) {
-                               $tags[] = $contact;
-                       }
+       // Add a tag if the parent contact is from ActivityPub or OStatus (This will notify them)
+       if ($parent && in_array($thr_parent_contact['network'], [Protocol::OSTATUS, Protocol::ACTIVITYPUB])) {
+               $contact = '@[url=' . $thr_parent_contact['url'] . ']' . $thr_parent_contact['nick'] . '[/url]';
+               if (!stripos(implode($tags), '[url=' . $thr_parent_contact['url'] . ']')) {
+                       $tags[] = $contact;
                }
        }
 
@@ -1026,8 +1017,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
                        $alias   = $contact["alias"];
                        $newname = $contact["nick"];
 
-                       if (($newname == "") || (($contact["network"] != Protocol::OSTATUS) && ($contact["network"] != Protocol::TWITTER)
-                               && ($contact["network"] != Protocol::STATUSNET))) {
+                       if (($newname == "") || !in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::OSTATUS, Protocol::TWITTER, Protocol::STATUSNET])) {
                                $newname = $contact["name"];
                        }
                }
index e205d72c6d93114d13b2c10708f4b80bcdefe684..568d6eb5371a7ffeaf73d44d7e43bbc5a1d4bc55 100644 (file)
@@ -472,7 +472,7 @@ function photos_post(App $a)
                        $uri = Item::newURI($page_owner_uid);
 
                        $arr = [];
-                       $arr['guid']          = System::createGUID(32);
+                       $arr['guid']          = System::createUUID();
                        $arr['uid']           = $page_owner_uid;
                        $arr['uri']           = $uri;
                        $arr['parent-uri']    = $uri;
@@ -651,7 +651,7 @@ function photos_post(App $a)
                                        $uri = Item::newURI($page_owner_uid);
 
                                        $arr = [];
-                                       $arr['guid']          = System::createGUID(32);
+                                       $arr['guid']          = System::createUUID();
                                        $arr['uid']           = $page_owner_uid;
                                        $arr['uri']           = $uri;
                                        $arr['parent-uri']    = $uri;
@@ -889,7 +889,7 @@ function photos_post(App $a)
                $arr['coord'] = $lat . ' ' . $lon;
        }
 
-       $arr['guid']          = System::createGUID(32);
+       $arr['guid']          = System::createUUID();
        $arr['uid']           = $page_owner_uid;
        $arr['uri']           = $uri;
        $arr['parent-uri']    = $uri;
index 91f33c0def2fd43a2991fb1aef40b41109f0f9da..6ebb8632c18b3a24bc229b2c300fc1a8e346e97f 100644 (file)
@@ -97,7 +97,7 @@ function poke_init(App $a)
 
        $arr = [];
 
-       $arr['guid']          = System::createGUID(32);
+       $arr['guid']          = System::createUUID();
        $arr['uid']           = $uid;
        $arr['uri']           = $uri;
        $arr['parent-uri']    = (!empty($parent_uri) ? $parent_uri : $uri);
index 2e3ccd28c52a8769f57c36df7160c841f96c5e45..e20836a0598cd55d2fb07f3b59fdff477a0abecc 100644 (file)
@@ -20,6 +20,7 @@ use Friendica\Model\Profile;
 use Friendica\Module\Login;
 use Friendica\Protocol\DFRN;
 use Friendica\Util\DateTimeFormat;
+use Friendica\Protocol\ActivityPub;
 
 function profile_init(App $a)
 {
@@ -49,6 +50,16 @@ function profile_init(App $a)
                DFRN::autoRedir($a, $which);
        }
 
+       if (ActivityPub::isRequest()) {
+               $user = DBA::selectFirst('user', ['uid'], ['nickname' => $which]);
+               if (DBA::isResult($user)) {
+                       $data = ActivityPub::profile($user['uid']);
+                       echo json_encode($data);
+                       header('Content-Type: application/activity+json');
+                       exit();
+               }
+       }
+
        Profile::load($a, $which, $profile);
 
        $blocked   = !local_user() && !remote_user() && Config::get('system', 'block_public');
index 1153f2147d7c5efcb11f2f71b141fda086640253..105cf60feb7f1e3d3a3ba458c3b37625a149f29c 100644 (file)
@@ -108,7 +108,7 @@ EOT;
 
        $arr = [];
 
-       $arr['guid'] = System::createGUID(32);
+       $arr['guid'] = System::createUUID();
        $arr['uri'] = $uri;
        $arr['uid'] = $owner_uid;
        $arr['contact-id'] = $contact['id'];
index 959394c07881a1e8b0b9c7dd43623d77b000eac3..fd79d54150df6d60defe34a7b88f7616d278ad86 100644 (file)
@@ -115,7 +115,7 @@ EOT;
 
        $arr = [];
 
-       $arr['guid'] = System::createGUID(32);
+       $arr['guid'] = System::createUUID();
        $arr['uri'] = $uri;
        $arr['uid'] = $owner_uid;
        $arr['contact-id'] = $contact['id'];
index 61505f29966e99d2ea4f66f27d2cb091a8bf16cc..6a5fdbbdb9257b78476789762bd99b5774fa25ab 100644 (file)
@@ -80,6 +80,7 @@ function xrd_json($a, $uri, $alias, $profile_url, $r)
                        ['rel' => NAMESPACE_DFRN, 'href' => $profile_url],
                        ['rel' => NAMESPACE_FEED, 'type' => 'application/atom+xml', 'href' => System::baseUrl().'/dfrn_poll/'.$r['nickname']],
                        ['rel' => 'http://webfinger.net/rel/profile-page', 'type' => 'text/html', 'href' => $profile_url],
+                       ['rel' => 'self', 'type' => 'application/activity+json', 'href' => $profile_url],
                        ['rel' => 'http://microformats.org/profile/hcard', 'type' => 'text/html', 'href' => System::baseUrl().'/hcard/'.$r['nickname']],
                        ['rel' => NAMESPACE_POCO, 'href' => System::baseUrl().'/poco/'.$r['nickname']],
                        ['rel' => 'http://webfinger.net/rel/avatar', 'type' => 'image/jpeg', 'href' => System::baseUrl().'/photo/profile/'.$r['uid'].'.jpg'],
@@ -92,6 +93,7 @@ function xrd_json($a, $uri, $alias, $profile_url, $r)
                        ['rel' => 'http://purl.org/openwebauth/v1', 'type' => 'application/x-dfrn+json', 'href' => System::baseUrl().'/owa']
                ]
        ];
+
        echo json_encode($json);
        killme();
 }
index 3ad4a4f055a7be33ebba9b3a1dfe42556ca7f11c..1da9397a7833da42e8ab778f8268544c02344f17 100644 (file)
@@ -21,7 +21,16 @@ abstract class BaseModule extends BaseObject
         */
        public static function init()
        {
+       }
 
+       /**
+        * @brief Module GET method to display raw content from technical endpoints
+        *
+        * Extend this method if the module is supposed to return communication data,
+        * e.g. from protocol implementations.
+        */
+       public static function rawContent()
+       {
        }
 
        /**
index d5efecb8060d420564ea2020417fd70cb5432ed8..6a701f25f355d11b87db1afe07f5222cb3584236 100644 (file)
@@ -75,21 +75,22 @@ class ContactSelector
        public static function networkToName($s, $profile = "")
        {
                $nets = [
-                       Protocol::DFRN      => L10n::t('Friendica'),
-                       Protocol::OSTATUS   => L10n::t('OStatus'),
-                       Protocol::FEED      => L10n::t('RSS/Atom'),
-                       Protocol::MAIL      => L10n::t('Email'),
-                       Protocol::DIASPORA  => L10n::t('Diaspora'),
-                       Protocol::ZOT       => L10n::t('Zot!'),
-                       Protocol::LINKEDIN  => L10n::t('LinkedIn'),
-                       Protocol::XMPP      => L10n::t('XMPP/IM'),
-                       Protocol::MYSPACE   => L10n::t('MySpace'),
-                       Protocol::GPLUS     => L10n::t('Google+'),
-                       Protocol::PUMPIO    => L10n::t('pump.io'),
-                       Protocol::TWITTER   => L10n::t('Twitter'),
-                       Protocol::DIASPORA2 => L10n::t('Diaspora Connector'),
-                       Protocol::STATUSNET => L10n::t('GNU Social Connector'),
-                       Protocol::PNUT      => L10n::t('pnut'),
+                       Protocol::DFRN      =>   L10n::t('Friendica'),
+                       Protocol::OSTATUS   =>   L10n::t('OStatus'),
+                       Protocol::FEED      =>   L10n::t('RSS/Atom'),
+                       Protocol::MAIL      =>   L10n::t('Email'),
+                       Protocol::DIASPORA  =>   L10n::t('Diaspora'),
+                       Protocol::ZOT       =>   L10n::t('Zot!'),
+                       Protocol::LINKEDIN  =>   L10n::t('LinkedIn'),
+                       Protocol::XMPP      =>   L10n::t('XMPP/IM'),
+                       Protocol::MYSPACE   =>   L10n::t('MySpace'),
+                       Protocol::GPLUS     =>   L10n::t('Google+'),
+                       Protocol::PUMPIO    =>   L10n::t('pump.io'),
+                       Protocol::TWITTER   =>   L10n::t('Twitter'),
+                       Protocol::DIASPORA2 =>   L10n::t('Diaspora Connector'),
+                       Protocol::STATUSNET =>   L10n::t('GNU Social Connector'),
+                       Protocol::ACTIVITYPUB => L10n::t('ActivityPub'),
+                       Protocol::PNUT      =>   L10n::t('pnut'),
                ];
 
                Addon::callHooks('network_to_name', $nets);
@@ -99,13 +100,17 @@ class ContactSelector
 
                $networkname = str_replace($search, $replace, $s);
 
-               if ((in_array($s, [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
+               if ((in_array($s, [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) && ($profile != "")) {
                        $r = DBA::fetchFirst("SELECT `gserver`.`platform` FROM `gcontact`
                                        INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
                                        WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
 
                        if (DBA::isResult($r)) {
                                $networkname = $r['platform'];
+
+                               if ($s == Protocol::ACTIVITYPUB) {
+                                       $networkname .= ' (AP)';
+                               }
                        }
                }
 
index f245f0d95e064819b1b6d4ae4a37cc4540f07a72..faba55b7a860b483e28022e98909d85eaa2cb899 100644 (file)
@@ -142,10 +142,7 @@ class Widget
 
                $nets = array();
                while ($rr = DBA::fetch($r)) {
-                       /// @TODO If 'network' is not there, this triggers an E_NOTICE
-                       if ($rr['network']) {
-                               $nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
-                       }
+                       $nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
                }
                DBA::close($r);
 
index 88b89cda27ac60189375854ecca2a103439ff4d2..b41f520d7792c614414cda5701ab8e8ab3ee22ed 100644 (file)
@@ -161,6 +161,18 @@ class System extends BaseObject
                killme();
        }
 
+       /**
+        * Generates a random string in the UUID format
+        *
+        * @param bool|string  $prefix   A given prefix (default is empty)
+        * @return string a generated UUID
+        */
+       public static function createUUID($prefix = '')
+       {
+               $guid = System::createGUID(32, $prefix);
+               return substr($guid, 0, 8). '-' . substr($guid, 8, 4) . '-' . substr($guid, 12, 4) . '-' . substr($guid, 16, 4) . '-' . substr($guid, 20, 12);
+       }
+
        /**
         * Generates a GUID with the given parameters
         *
diff --git a/src/Model/APContact.php b/src/Model/APContact.php
new file mode 100644 (file)
index 0000000..efd6ed0
--- /dev/null
@@ -0,0 +1,175 @@
+<?php
+
+/**
+ * @file src/Model/APContact.php
+ */
+
+namespace Friendica\Model;
+
+use Friendica\BaseObject;
+use Friendica\Database\DBA;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Util\Network;
+use Friendica\Util\JsonLD;
+use Friendica\Util\DateTimeFormat;
+
+require_once 'boot.php';
+
+class APContact extends BaseObject
+{
+       /**
+        * Resolves the profile url from the address by using webfinger
+        *
+        * @param string $addr profile address (user@domain.tld)
+        * @return string url
+        */
+       private static function addrToUrl($addr)
+       {
+               $addr_parts = explode('@', $addr);
+               if (count($addr_parts) != 2) {
+                       return false;
+               }
+
+               $webfinger = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
+
+               $ret = Network::curl($webfinger, false, $redirects, ['accept_content' => 'application/jrd+json,application/json']);
+               if (!$ret['success'] || empty($ret['body'])) {
+                       return false;
+               }
+
+               $data = json_decode($ret['body'], true);
+
+               if (empty($data['links'])) {
+                       return false;
+               }
+
+               foreach ($data['links'] as $link) {
+                       if (empty($link['href']) || empty($link['rel']) || empty($link['type'])) {
+                               continue;
+                       }
+
+                       if (($link['rel'] == 'self') && ($link['type'] == 'application/activity+json')) {
+                               return $link['href'];
+                       }
+               }
+
+               return false;
+       }
+
+       /**
+        * Fetches a profile from a given url
+        *
+        * @param string  $url    profile url
+        * @param boolean $update true = always update, false = never update, null = update when not found
+        * @return array profile array
+        */
+       public static function getByURL($url, $update = null)
+       {
+               if (empty($url)) {
+                       return false;
+               }
+
+               if (empty($update)) {
+                       $apcontact = DBA::selectFirst('apcontact', [], ['url' => $url]);
+                       if (DBA::isResult($apcontact)) {
+                               return $apcontact;
+                       }
+
+                       $apcontact = DBA::selectFirst('apcontact', [], ['alias' => $url]);
+                       if (DBA::isResult($apcontact)) {
+                               return $apcontact;
+                       }
+
+                       $apcontact = DBA::selectFirst('apcontact', [], ['addr' => $url]);
+                       if (DBA::isResult($apcontact)) {
+                               return $apcontact;
+                       }
+
+                       if (!is_null($update)) {
+                               return false;
+                       }
+               }
+
+               if (empty(parse_url($url, PHP_URL_SCHEME))) {
+                       $url = self::addrToUrl($url);
+                       if (empty($url)) {
+                               return false;
+                       }
+               }
+
+               $data = ActivityPub::fetchContent($url);
+
+               if (empty($data) || empty($data['id']) || empty($data['inbox'])) {
+                       return false;
+               }
+
+               $apcontact = [];
+               $apcontact['url'] = $data['id'];
+               $apcontact['uuid'] = defaults($data, 'diaspora:guid', null);
+               $apcontact['type'] = defaults($data, 'type', null);
+               $apcontact['following'] = defaults($data, 'following', null);
+               $apcontact['followers'] = defaults($data, 'followers', null);
+               $apcontact['inbox'] = defaults($data, 'inbox', null);
+               $apcontact['outbox'] = defaults($data, 'outbox', null);
+               $apcontact['sharedinbox'] = JsonLD::fetchElement($data, 'endpoints', 'sharedInbox');
+               $apcontact['nick'] = defaults($data, 'preferredUsername', null);
+               $apcontact['name'] = defaults($data, 'name', $apcontact['nick']);
+               $apcontact['about'] = defaults($data, 'summary', '');
+               $apcontact['photo'] = JsonLD::fetchElement($data, 'icon', 'url');
+               $apcontact['alias'] = JsonLD::fetchElement($data, 'url', 'href');
+
+               $parts = parse_url($apcontact['url']);
+               unset($parts['scheme']);
+               unset($parts['path']);
+               $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts));
+
+               $apcontact['pubkey'] = trim(JsonLD::fetchElement($data, 'publicKey', 'publicKeyPem'));
+
+               // To-Do
+               // manuallyApprovesFollowers
+
+               // Unhandled
+               // @context, tag, attachment, image, nomadicLocations, signature, following, followers, featured, movedTo, liked
+
+               // Unhandled from Misskey
+               // sharedInbox, isCat
+
+               // Unhandled from Kroeg
+               // kroeg:blocks, updated
+
+               // Check if the address is resolvable
+               if (self::addrToUrl($apcontact['addr']) == $apcontact['url']) {
+                       $parts = parse_url($apcontact['url']);
+                       unset($parts['path']);
+                       $apcontact['baseurl'] = Network::unparseURL($parts);
+               } else {
+                       $apcontact['addr'] = null;
+                       $apcontact['baseurl'] = null;
+               }
+
+               if ($apcontact['url'] == $apcontact['alias']) {
+                       $apcontact['alias'] = null;
+               }
+
+               $apcontact['updated'] = DateTimeFormat::utcNow();
+
+               DBA::update('apcontact', $apcontact, ['url' => $url], true);
+
+               // Update some data in the contact table with various ways to catch them all
+               $contact_fields = ['name' => $apcontact['name'], 'about' => $apcontact['about']];
+               DBA::update('contact', $contact_fields, ['nurl' => normalise_link($url)]);
+
+               $contacts = DBA::select('contact', ['uid', 'id'], ['nurl' => normalise_link($url)]);
+               while ($contact = DBA::fetch($contacts)) {
+                       Contact::updateAvatar($apcontact['photo'], $contact['uid'], $contact['id']);
+               }
+               DBA::close($contacts);
+
+               // Update the gcontact table
+               DBA::update('gcontact', $contact_fields, ['nurl' => normalise_link($url)]);
+
+               logger('Updated profile for ' . $url, LOGGER_DEBUG);
+
+               return $apcontact;
+       }
+}
index 1bbc0228a806a46dc7729ef1a852e7d12d53cb81..b6b708162621b0cfa7d3e51ebd1e79204f7233b6 100644 (file)
@@ -16,6 +16,7 @@ use Friendica\Database\DBA;
 use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
+use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\DFRN;
 use Friendica\Protocol\OStatus;
@@ -555,6 +556,12 @@ class Contact extends BaseObject
                        }
                } elseif ($contact['network'] == Protocol::DIASPORA) {
                        Diaspora::sendUnshare($user, $contact);
+               } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
+                       ActivityPub::transmitContactUndo($contact['url'], $user['uid']);
+
+                       if ($dissolve) {
+                               ActivityPub::transmitContactReject($contact['url'], $contact['hub-verify'], $user['uid']);
+                       }
                }
        }
 
@@ -775,7 +782,7 @@ class Contact extends BaseObject
                }
 
                if ((empty($profile["addr"]) || empty($profile["name"])) && (defaults($profile, "gid", 0) != 0)
-                       && in_array($profile["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])
+                       && in_array($profile["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])
                ) {
                        Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]);
                }
@@ -1054,7 +1061,6 @@ class Contact extends BaseObject
                        if (!x($contact, 'avatar')) {
                                $update_contact = true;
                        }
-
                        if (!$update_contact || $no_update) {
                                return $contact_id;
                        }
@@ -1088,7 +1094,7 @@ class Contact extends BaseObject
                }
 
                // Last try in gcontact for unsupported networks
-               if (!in_array($data["network"], [Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::PUMPIO, Protocol::MAIL, Protocol::FEED])) {
+               if (!in_array($data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA, Protocol::PUMPIO, Protocol::MAIL, Protocol::FEED])) {
                        if ($uid != 0) {
                                return 0;
                        }
@@ -1316,33 +1322,27 @@ class Contact extends BaseObject
 
                require_once 'include/conversation.php';
 
-               // There are no posts with "uid = 0" with connector networks
-               // This speeds up the query a lot
-               $r = q("SELECT `network`, `id` AS `author-id`, `contact-type` FROM `contact`
-                       WHERE `contact`.`nurl` = '%s' AND `contact`.`uid` = 0",
-                       DBA::escape(normalise_link($contact_url))
-               );
+               $cid = Self::getIdForURL($contact_url);
 
-               if (!DBA::isResult($r)) {
+               $contact = DBA::selectFirst('contact', ['contact-type', 'network'], ['id' => $cid]);
+               if (!DBA::isResult($contact)) {
                        return '';
                }
 
-               if (in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
+               if (in_array($contact["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                        $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))";
                } else {
                        $sql = "`item`.`uid` = ?";
                }
 
-               $author_id = intval($r[0]["author-id"]);
-
-               $contact = ($r[0]["contact-type"] == self::ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
+               $contact_field = ($contact["contact-type"] == self::ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
 
                if ($thread_mode) {
-                       $condition = ["`$contact` = ? AND `gravity` = ? AND " . $sql,
-                               $author_id, GRAVITY_PARENT, local_user()];
+                       $condition = ["`$contact_field` = ? AND `gravity` = ? AND " . $sql,
+                               $cid, GRAVITY_PARENT, local_user()];
                } else {
-                       $condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql,
-                               $author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
+                       $condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
+                               $cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
                }
 
                $params = ['order' => ['created' => true],
@@ -1495,10 +1495,11 @@ class Contact extends BaseObject
        }
 
        /**
-        * @param integer $id contact id
+        * @param integer $id      contact id
+        * @param string  $network Optional network we are probing for
         * @return boolean
         */
-       public static function updateFromProbe($id)
+       public static function updateFromProbe($id, $network = '')
        {
                /*
                  Warning: Never ever fetch the public key via Probe::uri and write it into the contacts.
@@ -1511,10 +1512,10 @@ class Contact extends BaseObject
                        return false;
                }
 
-               $ret = Probe::uri($contact["url"]);
+               $ret = Probe::uri($contact["url"], $network);
 
                // If Probe::uri fails the network code will be different
-               if ($ret["network"] != $contact["network"]) {
+               if (($ret["network"] != $contact["network"]) && ($ret["network"] != $network)) {
                        return false;
                }
 
@@ -1537,14 +1538,15 @@ class Contact extends BaseObject
 
                DBA::update(
                        'contact', [
-                               'url'    => $ret['url'],
-                               'nurl'   => normalise_link($ret['url']),
-                               'addr'   => $ret['addr'],
-                               'alias'  => $ret['alias'],
-                               'batch'  => $ret['batch'],
-                               'notify' => $ret['notify'],
-                               'poll'   => $ret['poll'],
-                               'poco'   => $ret['poco']
+                               'url'     => $ret['url'],
+                               'nurl'    => normalise_link($ret['url']),
+                               'network' => $ret['network'],
+                               'addr'    => $ret['addr'],
+                               'alias'   => $ret['alias'],
+                               'batch'   => $ret['batch'],
+                               'notify'  => $ret['notify'],
+                               'poll'    => $ret['poll'],
+                               'poco'    => $ret['poco']
                        ],
                        ['id' => $id]
                );
@@ -1686,7 +1688,7 @@ class Contact extends BaseObject
 
                $hidden = (($ret['network'] === Protocol::MAIL) ? 1 : 0);
 
-               if (in_array($ret['network'], [Protocol::MAIL, Protocol::DIASPORA])) {
+               if (in_array($ret['network'], [Protocol::MAIL, Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
                        $writeable = 1;
                }
 
@@ -1766,6 +1768,9 @@ class Contact extends BaseObject
                        } elseif ($contact['network'] == Protocol::DIASPORA) {
                                $ret = Diaspora::sendShare($a->user, $contact);
                                logger('share returns: ' . $ret);
+                       } elseif ($contact['network'] == Protocol::ACTIVITYPUB) {
+                               $ret = ActivityPub::transmitActivity('Follow', $contact['url'], $uid);
+                               logger('Follow returns: ' . $ret);
                        }
                }
 
@@ -1814,7 +1819,7 @@ class Contact extends BaseObject
                return $contact;
        }
 
-       public static function addRelationship($importer, $contact, $datarray, $item, $sharing = false) {
+       public static function addRelationship($importer, $contact, $datarray, $item = '', $sharing = false) {
                // Should always be set
                if (empty($datarray['author-id'])) {
                        return;
@@ -1827,7 +1832,7 @@ class Contact extends BaseObject
                        return;
                }
 
-               $url = $pub_contact['url'];
+               $url = defaults($datarray, 'author-link', $pub_contact['url']);
                $name = $pub_contact['name'];
                $photo = $pub_contact['photo'];
                $nick = $pub_contact['nick'];
@@ -1839,13 +1844,17 @@ class Contact extends BaseObject
                                DBA::update('contact', ['rel' => self::FRIEND, 'writable' => true],
                                                ['id' => $contact['id'], 'uid' => $importer['uid']]);
                        }
+
+                       if ($contact['network'] == Protocol::ACTIVITYPUB) {
+                               ActivityPub::transmitContactAccept($contact['url'], $contact['hub-verify'], $importer['uid']);
+                       }
+
                        // send email notification to owner?
                } else {
                        if (DBA::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) {
                                logger('ignoring duplicated connection request from pending contact ' . $url);
                                return;
                        }
-
                        // create contact record
                        q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
                                `blocked`, `readonly`, `pending`, `writable`)
index 0692a7341234f66f81530474270af6e4a64f85e8..be1eaf2295582a7e1bb1e0777cd7410a63e56f83 100644 (file)
@@ -17,13 +17,14 @@ class Conversation
         * These constants represent the parcel format used to transport a conversation independently of the message protocol.
         * It currently is stored in the "protocol" field for legacy reasons.
         */
-       const PARCEL_UNKNOWN            = 0;
+       const PARCEL_ACTIVITYPUB        = 0;
        const PARCEL_DFRN               = 1;
        const PARCEL_DIASPORA           = 2;
        const PARCEL_SALMON             = 3;
        const PARCEL_FEED               = 4; // Deprecated
        const PARCEL_SPLIT_CONVERSATION = 6;
        const PARCEL_TWITTER            = 67;
+       const PARCEL_UNKNOWN            = 255;
 
        /**
         * @brief Store the conversation data
@@ -34,7 +35,7 @@ class Conversation
        public static function insert(array $arr)
        {
                if (in_array(defaults($arr, 'network', Protocol::PHANTOM),
-                               [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
+                       [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
                        $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
 
                        if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
@@ -70,7 +71,8 @@ class Conversation
                                        unset($old_conv['source']);
                                }
                                // Update structure data all the time but the source only when its from a better protocol.
-                               if (isset($conversation['protocol']) && isset($conversation['source']) && ($old_conv['protocol'] < $conversation['protocol']) && ($old_conv['protocol'] != 0)) {
+                               if (empty($conversation['source']) || (!empty($old_conv['source']) &&
+                                       ($old_conv['protocol'] < defaults($conversation, 'protocol', PARCEL_UNKNOWN)))) {
                                        unset($conversation['protocol']);
                                        unset($conversation['source']);
                                }
index 016d1f8d9e3974a47ec0197223a1ec4fda5ece83..452017e69d3a04bcfbd2269d851b1db69340f9ee 100644 (file)
@@ -314,7 +314,7 @@ class Event extends BaseObject
 
                        Addon::callHooks('event_updated', $event['id']);
                } else {
-                       $event['guid']  = defaults($arr, 'guid', System::createGUID(32));
+                       $event['guid']  = defaults($arr, 'guid', System::createUUID());
 
                        // New event. Store it.
                        DBA::insert('event', $event);
index 748dccadfab598c0385d23fbf2e83e924aa95917..2c9be633a9ae8083e1c2178d140bfac0895ed5a9 100644 (file)
@@ -176,7 +176,7 @@ class Item extends BaseObject
 
                // We can always comment on posts from these networks
                if (array_key_exists('writable', $row) &&
-                       in_array($row['internal-network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+                       in_array($row['internal-network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        $row['writable'] = true;
                }
 
@@ -1081,9 +1081,8 @@ class Item extends BaseObject
 
                DBA::delete('item-delivery-data', ['iid' => $item['id']]);
 
-               if (!empty($item['iaid']) && !self::exists(['iaid' => $item['iaid'], 'deleted' => false])) {
-                       DBA::delete('item-activity', ['id' => $item['iaid']], ['cascade' => false]);
-               }
+               // We don't delete the item-activity here, since we need some of the data for ActivityPub
+
                if (!empty($item['icid']) && !self::exists(['icid' => $item['icid'], 'deleted' => false])) {
                        DBA::delete('item-content', ['id' => $item['icid']], ['cascade' => false]);
                }
@@ -1205,7 +1204,7 @@ class Item extends BaseObject
                } elseif (!empty($item['uri'])) {
                        $guid = self::guidFromUri($item['uri'], $prefix_host);
                } else {
-                       $guid = System::createGUID(32, hash('crc32', $prefix_host));
+                       $guid = System::createUUID(hash('crc32', $prefix_host));
                }
 
                return $guid;
@@ -1352,7 +1351,7 @@ class Item extends BaseObject
                 * We have to check several networks since Friendica posts could be repeated
                 * via OStatus (maybe Diasporsa as well)
                 */
-               if (in_array($item['network'], [Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS, ""])) {
+               if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS, ""])) {
                        $condition = ["`uri` = ? AND `uid` = ? AND `network` IN (?, ?, ?)",
                                trim($item['uri']), $item['uid'],
                                Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS];
@@ -2054,7 +2053,7 @@ class Item extends BaseObject
 
                // Only distribute public items from native networks
                $condition = ['id' => $itemid, 'uid' => 0,
-                       'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
+                       'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
                        'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
                $item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
                if (!DBA::isResult($item)) {
@@ -2072,14 +2071,46 @@ class Item extends BaseObject
 
                $users = [];
 
-               $condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)",
-                       $parent['owner-id'], Contact::SHARING,  Contact::FRIEND];
+               /// @todo add a field "pcid" in the contact table that referrs to the public contact id.
+               $owner = DBA::selectFirst('contact', ['url', 'nurl', 'alias'], ['id' => $parent['owner-id']]);
+               if (!DBA::isResult($owner)) {
+                       return;
+               }
 
+               $condition = ['nurl' => $owner['nurl'], 'rel' => [Contact::SHARING, Contact::FRIEND]];
                $contacts = DBA::select('contact', ['uid'], $condition);
+               while ($contact = DBA::fetch($contacts)) {
+                       if ($contact['uid'] == 0) {
+                               continue;
+                       }
 
+                       $users[$contact['uid']] = $contact['uid'];
+               }
+               DBA::close($contacts);
+
+               $condition = ['alias' => $owner['url'], 'rel' => [Contact::SHARING, Contact::FRIEND]];
+               $contacts = DBA::select('contact', ['uid'], $condition);
                while ($contact = DBA::fetch($contacts)) {
+                       if ($contact['uid'] == 0) {
+                               continue;
+                       }
+
                        $users[$contact['uid']] = $contact['uid'];
                }
+               DBA::close($contacts);
+
+               if (!empty($owner['alias'])) {
+                       $condition = ['url' => $owner['alias'], 'rel' => [Contact::SHARING, Contact::FRIEND]];
+                       $contacts = DBA::select('contact', ['uid'], $condition);
+                       while ($contact = DBA::fetch($contacts)) {
+                               if ($contact['uid'] == 0) {
+                                       continue;
+                               }
+
+                               $users[$contact['uid']] = $contact['uid'];
+                       }
+                       DBA::close($contacts);
+               }
 
                $origin_uid = 0;
 
@@ -2176,7 +2207,7 @@ class Item extends BaseObject
                }
 
                // is it an entry from a connector? Only add an entry for natively connected networks
-               if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
+               if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""])) {
                        return;
                }
 
@@ -2327,16 +2358,10 @@ class Item extends BaseObject
        public static function newURI($uid, $guid = "")
        {
                if ($guid == "") {
-                       $guid = System::createGUID(32);
+                       $guid = System::createUUID();
                }
 
-               $hostname = self::getApp()->get_hostname();
-
-               $user = DBA::selectFirst('user', ['nickname'], ['uid' => $uid]);
-
-               $uri = "urn:X-dfrn:" . $hostname . ':' . $user['nickname'] . ':' . $guid;
-
-               return $uri;
+               return self::getApp()->get_baseurl() . '/object/' . $guid;
        }
 
        /**
@@ -2660,7 +2685,7 @@ class Item extends BaseObject
                        }
 
                        if ($contact['network'] != Protocol::FEED) {
-                               $datarray["guid"] = System::createGUID(32);
+                               $datarray["guid"] = System::createUUID();
                                unset($datarray["plink"]);
                                $datarray["uri"] = self::newURI($contact['uid'], $datarray["guid"]);
                                $datarray["parent-uri"] = $datarray["uri"];
@@ -2826,7 +2851,7 @@ class Item extends BaseObject
        }
 
        // returns an array of contact-ids that are allowed to see this object
-       private static function enumeratePermissions($obj)
+       public static function enumeratePermissions($obj)
        {
                $allow_people = expand_acl($obj['allow_cid']);
                $allow_groups = Group::expand(expand_acl($obj['allow_gid']));
@@ -3089,7 +3114,7 @@ class Item extends BaseObject
                $objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
 
                $new_item = [
-                       'guid'          => System::createGUID(32),
+                       'guid'          => System::createUUID(),
                        'uri'           => self::newURI($item['uid']),
                        'uid'           => $item['uid'],
                        'contact-id'    => $item_contact_id,
index 24a174b6b58251df7c5dd674c4ad75d207c50b46..49247ca69dfb1385eabd53cae08fd9144c4baab6 100644 (file)
@@ -46,7 +46,7 @@ class Mail
                        return -2;
                }
 
-               $guid = System::createGUID(32);
+               $guid = System::createUUID();
                $uri = 'urn:X-dfrn:' . System::baseUrl() . ':' . local_user() . ':' . $guid;
 
                $convid = 0;
@@ -73,7 +73,7 @@ class Mail
                        $recip_handle = (($contact['addr']) ? $contact['addr'] : $contact['nick'] . '@' . $recip_host);
                        $sender_handle = $a->user['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
 
-                       $conv_guid = System::createGUID(32);
+                       $conv_guid = System::createUUID();
                        $convuri = $recip_handle . ':' . $conv_guid;
 
                        $handles = $recip_handle . ';' . $sender_handle;
@@ -171,7 +171,7 @@ class Mail
                        $subject = L10n::t('[no subject]');
                }
 
-               $guid = System::createGUID(32);
+               $guid = System::createUUID();
                $uri = 'urn:X-dfrn:' . System::baseUrl() . ':' . local_user() . ':' . $guid;
 
                $me = Probe::uri($replyto);
@@ -180,7 +180,7 @@ class Mail
                        return -2;
                }
 
-               $conv_guid = System::createGUID(32);
+               $conv_guid = System::createUUID();
 
                $recip_handle = $recipient['nickname'] . '@' . substr(System::baseUrl(), strpos(System::baseUrl(), '://') + 3);
 
index 3a014517da9b158875c176c4654c0428e3686f95..cb2754cc80ce6a8ef218421ec7952ccb00327fed 100644 (file)
@@ -28,6 +28,19 @@ require_once 'include/dba.php';
 
 class Profile
 {
+       /**
+        * @brief Returns default profile for a given user id
+        *
+        * @param integer User ID
+        *
+        * @return array Profile data
+        */
+       public static function getByUID($uid)
+       {
+               $profile = DBA::selectFirst('profile', [], ['uid' => $uid, 'is-default' => true]);
+               return $profile;
+       }
+
        /**
         * @brief Returns a formatted location string from the given profile array
         *
index a81241cb42af31298fe95bea2d64753d3d04c79f..854861ccb589b022609d48000a7b21f0d2ce286c 100644 (file)
@@ -33,6 +33,17 @@ class Term
                return $tag_text;
        }
 
+       public static function tagArrayFromItemId($itemid, $type = [TERM_HASHTAG, TERM_MENTION])
+       {
+               $condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => $type];
+               $tags = DBA::select('term', ['type', 'term', 'url'], $condition);
+               if (!DBA::isResult($tags)) {
+                       return [];
+               }
+
+               return DBA::toArray($tags);
+       }
+
        public static function fileTextFromItemId($itemid)
        {
                $file_text = '';
@@ -99,6 +110,18 @@ class Term
                $pattern = '/\W([\#@])\[url\=(.*?)\](.*?)\[\/url\]/ism';
                if (preg_match_all($pattern, $data, $matches, PREG_SET_ORDER)) {
                        foreach ($matches as $match) {
+
+                               if ($match[1] == '@') {
+                                       $contact = Contact::getDetailsByURL($match[2], 0);
+                                       if (!empty($contact['addr'])) {
+                                               $match[3] = $contact['addr'];
+                                       }
+
+                                       if (!empty($contact['url'])) {
+                                               $match[2] = $contact['url'];
+                                       }
+                               }
+
                                $tags[$match[1] . trim($match[3], ',.:;[]/\"?!')] = $match[2];
                        }
                }
@@ -119,12 +142,22 @@ class Term
                                $term = substr($tag, 1);
                        } elseif (substr(trim($tag), 0, 1) == '@') {
                                $type = TERM_MENTION;
-                               $term = substr($tag, 1);
+
+                               $contact = Contact::getDetailsByURL($link, 0);
+                               if (!empty($contact['name'])) {
+                                       $term = $contact['name'];
+                               } else {
+                                       $term = substr($tag, 1);
+                               }
                        } else { // This shouldn't happen
                                $type = TERM_HASHTAG;
                                $term = $tag;
                        }
 
+                       if (DBA::exists('term', ['uid' => $message['uid'], 'otype' => TERM_OBJ_POST, 'oid' => $itemid, 'url' => $link])) {
+                               continue;
+                       }
+
                        if ($message['uid'] == 0) {
                                $global = true;
                                DBA::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
index d65e7d8f9699e41aabadb406bd3034bd7da2266f..7432b75774b22516165ad664e1102fb4d3f97f91 100644 (file)
@@ -31,6 +31,23 @@ require_once 'include/text.php';
  */
 class User
 {
+       /**
+        * @brief Returns the user id of a given profile url
+        *
+        * @param string $profile
+        *
+        * @return integer user id
+        */
+       public static function getIdForURL($url)
+       {
+               $self = DBA::selectFirst('contact', ['uid'], ['nurl' => normalise_link($url), 'self' => true]);
+               if (!DBA::isResult($self)) {
+                       return false;
+               } else {
+                       return $self['uid'];
+               }
+       }
+
        /**
         * @brief Get owner data by user id
         *
@@ -495,7 +512,7 @@ class User
                $spubkey = $sres['pubkey'];
 
                $insert_result = DBA::insert('user', [
-                       'guid'     => System::createGUID(32),
+                       'guid'     => System::createUUID(),
                        'username' => $username,
                        'password' => $new_password_encoded,
                        'email'    => $email,
diff --git a/src/Module/Followers.php b/src/Module/Followers.php
new file mode 100644 (file)
index 0000000..98e9f1e
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @file src/Module/Followers.php
+ */
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Core\System;
+use Friendica\Model\User;
+
+/**
+ * ActivityPub Followers
+ */
+class Followers extends BaseModule
+{
+       public static function rawContent()
+       {
+               $a = self::getApp();
+
+               if (empty($a->argv[1])) {
+                       System::httpExit(404);
+               }
+
+               $owner = User::getOwnerDataByNick($a->argv[1]);
+               if (empty($owner)) {
+                       System::httpExit(404);
+               }
+
+               $page = defaults($_REQUEST, 'page', null);
+
+               $followers = ActivityPub::getFollowers($owner, $page);
+
+               header('Content-Type: application/activity+json');
+               echo json_encode($followers);
+               exit();
+       }
+}
diff --git a/src/Module/Following.php b/src/Module/Following.php
new file mode 100644 (file)
index 0000000..6023db4
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @file src/Module/Following.php
+ */
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Core\System;
+use Friendica\Model\User;
+
+/**
+ * ActivityPub Following
+ */
+class Following extends BaseModule
+{
+       public static function rawContent()
+       {
+               $a = self::getApp();
+
+               if (empty($a->argv[1])) {
+                       System::httpExit(404);
+               }
+
+               $owner = User::getOwnerDataByNick($a->argv[1]);
+               if (empty($owner)) {
+                       System::httpExit(404);
+               }
+
+               $page = defaults($_REQUEST, 'page', null);
+
+               $Following = ActivityPub::getFollowing($owner, $page);
+
+               header('Content-Type: application/activity+json');
+               echo json_encode($Following);
+               exit();
+       }
+}
diff --git a/src/Module/Inbox.php b/src/Module/Inbox.php
new file mode 100644 (file)
index 0000000..c97c3b7
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * @file src/Module/Inbox.php
+ */
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Core\System;
+use Friendica\Database\DBA;
+use Friendica\Util\HTTPSignature;
+
+/**
+ * ActivityPub Inbox
+ */
+class Inbox extends BaseModule
+{
+       public static function rawContent()
+       {
+               $a = self::getApp();
+
+               $postdata = file_get_contents('php://input');
+
+               if (empty($postdata)) {
+                       System::httpExit(400);
+               }
+
+// Enable for test purposes
+/*
+               if (HTTPSignature::getSigner($postdata, $_SERVER)) {
+                       $filename = 'signed-activitypub';
+               } else {
+                       $filename = 'failed-activitypub';
+               }
+
+               $tempfile = tempnam(get_temppath(), $filename);
+               file_put_contents($tempfile, json_encode(['argv' => $a->argv, 'header' => $_SERVER, 'body' => $postdata], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
+
+               logger('Incoming message stored under ' . $tempfile);
+*/
+               if (!empty($a->argv[1])) {
+                       $user = DBA::selectFirst('user', ['uid'], ['nickname' => $a->argv[1]]);
+                       if (!DBA::isResult($user)) {
+                               System::httpExit(404);
+                       }
+                       $uid = $user['uid'];
+               } else {
+                       $uid = 0;
+               }
+
+               ActivityPub::processInbox($postdata, $_SERVER, $uid);
+
+               System::httpExit(202);
+       }
+}
index cf77482e5a8eec13d719bade0afdf9ada4bc2064..0b4126e0e965528fba0c9170a725c2b2dec262c9 100644 (file)
@@ -76,13 +76,9 @@ class Magic extends BaseModule
 
                                // Create a header that is signed with the local users private key.
                                $headers = HTTPSignature::createSig(
-                                       '',
                                        $headers,
                                        $user['prvkey'],
-                                       'acct:' . $user['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : ''),
-                                       false,
-                                       true,
-                                       'sha512'
+                                       'acct:' . $user['nickname'] . '@' . $a->get_hostname() . ($a->urlpath ? '/' . $a->urlpath : '')
                                );
 
                                // Try to get an authentication token from the other instance.
diff --git a/src/Module/Object.php b/src/Module/Object.php
new file mode 100644 (file)
index 0000000..05aae84
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @file src/Module/Object.php
+ */
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Core\System;
+use Friendica\Model\Item;
+use Friendica\Database\DBA;
+
+/**
+ * ActivityPub Object
+ */
+class Object extends BaseModule
+{
+       public static function rawContent()
+       {
+               $a = self::getApp();
+
+               if (empty($a->argv[1])) {
+                       System::httpExit(404);
+               }
+
+               if (!ActivityPub::isRequest()) {
+                       goaway(str_replace('object/', 'display/', $a->query_string));
+               }
+
+               $item = Item::selectFirst(['id'], ['guid' => $a->argv[1], 'wall' => true, 'private' => false]);
+               if (!DBA::isResult($item)) {
+                       System::httpExit(404);
+               }
+
+               $data = ActivityPub::createObjectFromItemID($item['id']);
+
+               header('Content-Type: application/activity+json');
+               echo json_encode($data);
+               exit();
+       }
+}
diff --git a/src/Module/Outbox.php b/src/Module/Outbox.php
new file mode 100644 (file)
index 0000000..f6bad56
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @file src/Module/Outbox.php
+ */
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Core\System;
+use Friendica\Model\User;
+
+/**
+ * ActivityPub Outbox
+ */
+class Outbox extends BaseModule
+{
+       public static function rawContent()
+       {
+               $a = self::getApp();
+
+               if (empty($a->argv[1])) {
+                       System::httpExit(404);
+               }
+
+               $owner = User::getOwnerDataByNick($a->argv[1]);
+               if (empty($owner)) {
+                       System::httpExit(404);
+               }
+
+               $page = defaults($_REQUEST, 'page', null);
+
+               $outbox = ActivityPub::getOutbox($owner, $page);
+
+               header('Content-Type: application/activity+json');
+               echo json_encode($outbox);
+               exit();
+       }
+}
index 1d6b1332dcec81bdcf8ff5bd8aba3111343338c4..7a5fe128c8424cea51c99de816e95dfae501a01b 100644 (file)
@@ -54,7 +54,7 @@ class Owa extends BaseModule
                                                if (DBA::isResult($contact)) {
                                                        // Try to verify the signed header with the public key of the contact record
                                                        // we have found.
-                                                       $verified = HTTPSignature::verify('', $contact['pubkey']);
+                                                       $verified = HTTPSignature::verifyMagic($contact['pubkey']);
 
                                                        if ($verified && $verified['header_signed'] && $verified['header_valid']) {
                                                                logger('OWA header: ' . print_r($verified, true), LOGGER_DATA);
index 75231f44ff0bc9e2e1061704cdcbdecc1df1783a..2c84ddb85a8312f42a6e3f5d5723051e56045161 100644 (file)
@@ -19,6 +19,7 @@ use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Protocol\Email;
 use Friendica\Protocol\Feed;
+use Friendica\Protocol\ActivityPub;
 use Friendica\Util\Crypto;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -328,7 +329,17 @@ class Probe
                        $uid = local_user();
                }
 
-               $data = self::detect($uri, $network, $uid);
+               if ($network != Protocol::ACTIVITYPUB) {
+                       $data = self::detect($uri, $network, $uid);
+               } else {
+                       $data = null;
+               }
+
+               $ap_profile = ActivityPub::probeProfile($uri);
+
+               if (!empty($ap_profile) && (defaults($data, 'network', '') != Protocol::DFRN)) {
+                       $data = $ap_profile;
+               }
 
                if (!isset($data["url"])) {
                        $data["url"] = $uri;
index c52078e521ef046150abb72fcb96782bb2ef0603..efd7d4dc8de3d1101da3f381b1f9895214ca0c8e 100644 (file)
@@ -324,7 +324,7 @@ class Post extends BaseObject
                $owner_name_e = $this->getOwnerName();
 
                // Disable features that aren't available in several networks
-               if (!in_array($item["network"], [Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
+               if (!in_array($item["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA]) && isset($buttons["dislike"])) {
                        unset($buttons["dislike"]);
                        $isevent = false;
                        $tagger = '';
diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php
new file mode 100644 (file)
index 0000000..b5cd102
--- /dev/null
@@ -0,0 +1,1944 @@
+<?php
+/**
+ * @file src/Protocol/ActivityPub.php
+ */
+namespace Friendica\Protocol;
+
+use Friendica\Database\DBA;
+use Friendica\Core\System;
+use Friendica\BaseObject;
+use Friendica\Util\Network;
+use Friendica\Util\HTTPSignature;
+use Friendica\Core\Protocol;
+use Friendica\Model\Conversation;
+use Friendica\Model\Contact;
+use Friendica\Model\APContact;
+use Friendica\Model\Item;
+use Friendica\Model\Profile;
+use Friendica\Model\Term;
+use Friendica\Model\User;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Crypto;
+use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\HTML;
+use Friendica\Util\JsonLD;
+use Friendica\Util\LDSignature;
+use Friendica\Core\Config;
+
+/**
+ * @brief ActivityPub Protocol class
+ * The ActivityPub Protocol is a message exchange protocol defined by the W3C.
+ * https://www.w3.org/TR/activitypub/
+ * https://www.w3.org/TR/activitystreams-core/
+ * https://www.w3.org/TR/activitystreams-vocabulary/
+ *
+ * https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
+ * https://blog.joinmastodon.org/2018/07/how-to-make-friends-and-verify-requests/
+ *
+ * Digest: https://tools.ietf.org/html/rfc5843
+ * https://tools.ietf.org/html/draft-cavage-http-signatures-10#ref-15
+ *
+ * Mastodon implementation of supported activities:
+ * https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/activity.rb#L26
+ *
+ * To-do:
+ *
+ * Receiver:
+ * - Update (Image, Video, Article, Note)
+ * - Event
+ * - Undo Announce
+ *
+ * Check what this is meant to do:
+ * - Add
+ * - Block
+ * - Flag
+ * - Remove
+ * - Undo Block
+ * - Undo Accept (Problem: This could invert a contact accept or an event accept)
+ *
+ * Transmitter:
+ * - Event
+ *
+ * Complicated:
+ * - Announce
+ * - Undo Announce
+ *
+ * General:
+ * - Attachments
+ * - nsfw (sensitive)
+ * - Queueing unsucessful deliveries
+ * - Polling the outboxes for missing content?
+ * - Possibly using the LD-JSON parser
+ */
+class ActivityPub
+{
+       const PUBLIC_COLLECTION = 'https://www.w3.org/ns/activitystreams#Public';
+       const CONTEXT = ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1',
+               ['vcard' => 'http://www.w3.org/2006/vcard/ns#',
+               'diaspora' => 'https://diasporafoundation.org/ns/',
+               'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
+               'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag']];
+       const ACCOUNT_TYPES = ['Person', 'Organization', 'Service', 'Group', 'Application'];
+       const CONTENT_TYPES = ['Note', 'Article', 'Video', 'Image'];
+       const ACTIVITY_TYPES = ['Like', 'Dislike', 'Accept', 'Reject', 'TentativeAccept'];
+       /**
+        * @brief Checks if the web request is done for the AP protocol
+        *
+        * @return is it AP?
+        */
+       public static function isRequest()
+       {
+               return stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json') ||
+                       stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/ld+json');
+       }
+
+       /**
+        * @brief collects the lost of followers of the given owner
+        *
+        * @param array $owner Owner array
+        * @param integer $page Page number
+        *
+        * @return array of owners
+        */
+       public static function getFollowers($owner, $page = null)
+       {
+               $condition = ['rel' => [Contact::FOLLOWER, Contact::FRIEND], 'network' => Protocol::NATIVE_SUPPORT, 'uid' => $owner['uid'],
+                       'self' => false, 'hidden' => false, 'archive' => false, 'pending' => false];
+               $count = DBA::count('contact', $condition);
+
+               $data = ['@context' => self::CONTEXT];
+               $data['id'] = System::baseUrl() . '/followers/' . $owner['nickname'];
+               $data['type'] = 'OrderedCollection';
+               $data['totalItems'] = $count;
+
+               // When we hide our friends we will only show the pure number but don't allow more.
+               $profile = Profile::getByUID($owner['uid']);
+               if (!empty($profile['hide-friends'])) {
+                       return $data;
+               }
+
+               if (empty($page)) {
+                       $data['first'] = System::baseUrl() . '/followers/' . $owner['nickname'] . '?page=1';
+               } else {
+                       $list = [];
+
+                       $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
+                       while ($contact = DBA::fetch($contacts)) {
+                               $list[] = $contact['url'];
+                       }
+
+                       if (!empty($list)) {
+                               $data['next'] = System::baseUrl() . '/followers/' . $owner['nickname'] . '?page=' . ($page + 1);
+                       }
+
+                       $data['partOf'] = System::baseUrl() . '/followers/' . $owner['nickname'];
+
+                       $data['orderedItems'] = $list;
+               }
+
+               return $data;
+       }
+
+       /**
+        * @brief Create list of following contacts
+        *
+        * @param array $owner Owner array
+        * @param integer $page Page numbe
+        *
+        * @return array of following contacts
+        */
+       public static function getFollowing($owner, $page = null)
+       {
+               $condition = ['rel' => [Contact::SHARING, Contact::FRIEND], 'network' => Protocol::NATIVE_SUPPORT, 'uid' => $owner['uid'],
+                       'self' => false, 'hidden' => false, 'archive' => false, 'pending' => false];
+               $count = DBA::count('contact', $condition);
+
+               $data = ['@context' => self::CONTEXT];
+               $data['id'] = System::baseUrl() . '/following/' . $owner['nickname'];
+               $data['type'] = 'OrderedCollection';
+               $data['totalItems'] = $count;
+
+               // When we hide our friends we will only show the pure number but don't allow more.
+               $profile = Profile::getByUID($owner['uid']);
+               if (!empty($profile['hide-friends'])) {
+                       return $data;
+               }
+
+               if (empty($page)) {
+                       $data['first'] = System::baseUrl() . '/following/' . $owner['nickname'] . '?page=1';
+               } else {
+                       $list = [];
+
+                       $contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
+                       while ($contact = DBA::fetch($contacts)) {
+                               $list[] = $contact['url'];
+                       }
+
+                       if (!empty($list)) {
+                               $data['next'] = System::baseUrl() . '/following/' . $owner['nickname'] . '?page=' . ($page + 1);
+                       }
+
+                       $data['partOf'] = System::baseUrl() . '/following/' . $owner['nickname'];
+
+                       $data['orderedItems'] = $list;
+               }
+
+               return $data;
+       }
+
+       /**
+        * @brief Public posts for the given owner
+        *
+        * @param array $owner Owner array
+        * @param integer $page Page numbe
+        *
+        * @return array of posts
+        */
+       public static function getOutbox($owner, $page = null)
+       {
+               $public_contact = Contact::getIdForURL($owner['url'], 0, true);
+
+               $condition = ['uid' => $owner['uid'], 'contact-id' => $owner['id'], 'author-id' => $public_contact,
+                       'wall' => true, 'private' => false, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT],
+                       'deleted' => false, 'visible' => true];
+               $count = DBA::count('item', $condition);
+
+               $data = ['@context' => self::CONTEXT];
+               $data['id'] = System::baseUrl() . '/outbox/' . $owner['nickname'];
+               $data['type'] = 'OrderedCollection';
+               $data['totalItems'] = $count;
+
+               if (empty($page)) {
+                       $data['first'] = System::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=1';
+               } else {
+                       $list = [];
+
+                       $condition['parent-network'] = Protocol::NATIVE_SUPPORT;
+
+                       $items = Item::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
+                       while ($item = Item::fetch($items)) {
+                               $object = self::createObjectFromItemID($item['id']);
+                               unset($object['@context']);
+                               $list[] = $object;
+                       }
+
+                       if (!empty($list)) {
+                               $data['next'] = System::baseUrl() . '/outbox/' . $owner['nickname'] . '?page=' . ($page + 1);
+                       }
+
+                       $data['partOf'] = System::baseUrl() . '/outbox/' . $owner['nickname'];
+
+                       $data['orderedItems'] = $list;
+               }
+
+               return $data;
+       }
+
+       /**
+        * Return the ActivityPub profile of the given user
+        *
+        * @param integer $uid User ID
+        * @return profile array
+        */
+       public static function profile($uid)
+       {
+               $condition = ['uid' => $uid, 'blocked' => false, 'account_expired' => false,
+                       'account_removed' => false, 'verified' => true];
+               $fields = ['guid', 'nickname', 'pubkey', 'account-type', 'page-flags'];
+               $user = DBA::selectFirst('user', $fields, $condition);
+               if (!DBA::isResult($user)) {
+                       return [];
+               }
+
+               $fields = ['locality', 'region', 'country-name'];
+               $profile = DBA::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]);
+               if (!DBA::isResult($profile)) {
+                       return [];
+               }
+
+               $fields = ['name', 'url', 'location', 'about', 'avatar'];
+               $contact = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
+               if (!DBA::isResult($contact)) {
+                       return [];
+               }
+
+               $data = ['@context' => self::CONTEXT];
+               $data['id'] = $contact['url'];
+               $data['diaspora:guid'] = $user['guid'];
+               $data['type'] = self::ACCOUNT_TYPES[$user['account-type']];
+               $data['following'] = System::baseUrl() . '/following/' . $user['nickname'];
+               $data['followers'] = System::baseUrl() . '/followers/' . $user['nickname'];
+               $data['inbox'] = System::baseUrl() . '/inbox/' . $user['nickname'];
+               $data['outbox'] = System::baseUrl() . '/outbox/' . $user['nickname'];
+               $data['preferredUsername'] = $user['nickname'];
+               $data['name'] = $contact['name'];
+               $data['vcard:hasAddress'] = ['@type' => 'vcard:Home', 'vcard:country-name' => $profile['country-name'],
+                       'vcard:region' => $profile['region'], 'vcard:locality' => $profile['locality']];
+               $data['summary'] = $contact['about'];
+               $data['url'] = $contact['url'];
+               $data['manuallyApprovesFollowers'] = in_array($user['page-flags'], [Contact::PAGE_NORMAL, Contact::PAGE_PRVGROUP]);
+               $data['publicKey'] = ['id' => $contact['url'] . '#main-key',
+                       'owner' => $contact['url'],
+                       'publicKeyPem' => $user['pubkey']];
+               $data['endpoints'] = ['sharedInbox' => System::baseUrl() . '/inbox'];
+               $data['icon'] = ['type' => 'Image',
+                       'url' => $contact['avatar']];
+
+               // tags: https://kitty.town/@inmysocks/100656097926961126.json
+               return $data;
+       }
+
+       /**
+        * @brief Returns an array with permissions of a given item array
+        *
+        * @param array $item
+        *
+        * @return array with permissions
+        */
+       private static function fetchPermissionBlockFromConversation($item)
+       {
+               if (empty($item['thr-parent'])) {
+                       return [];
+               }
+
+               $condition = ['item-uri' => $item['thr-parent'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
+               $conversation = DBA::selectFirst('conversation', ['source'], $condition);
+               if (!DBA::isResult($conversation)) {
+                       return [];
+               }
+
+               $activity = json_decode($conversation['source'], true);
+
+               $actor = JsonLD::fetchElement($activity, 'actor', 'id');
+               $profile = APContact::getByURL($actor);
+
+               $item_profile = APContact::getByURL($item['author-link']);
+               $exclude[] = $item['author-link'];
+
+               if ($item['gravity'] == GRAVITY_PARENT) {
+                       $exclude[] = $item['owner-link'];
+               }
+
+               $permissions['to'][] = $actor;
+
+               foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
+                       if (empty($activity[$element])) {
+                               continue;
+                       }
+                       if (is_string($activity[$element])) {
+                               $activity[$element] = [$activity[$element]];
+                       }
+
+                       foreach ($activity[$element] as $receiver) {
+                               if ($receiver == $profile['followers'] && !empty($item_profile['followers'])) {
+                                       $receiver = $item_profile['followers'];
+                               }
+                               if (!in_array($receiver, $exclude)) {
+                                       $permissions[$element][] = $receiver;
+                               }
+                       }
+               }
+               return $permissions;
+       }
+
+       /**
+        * @brief Creates an array of permissions from an item thread
+        *
+        * @param array $item
+        *
+        * @return permission array
+        */
+       public static function createPermissionBlockForItem($item)
+       {
+               $data = ['to' => [], 'cc' => []];
+
+               $data = array_merge($data, self::fetchPermissionBlockFromConversation($item));
+
+               $actor_profile = APContact::getByURL($item['author-link']);
+
+               $terms = Term::tagArrayFromItemId($item['id'], TERM_MENTION);
+
+               $contacts[$item['author-link']] = $item['author-link'];
+
+               if (!$item['private']) {
+                       $data['to'][] = self::PUBLIC_COLLECTION;
+                       if (!empty($actor_profile['followers'])) {
+                               $data['cc'][] = $actor_profile['followers'];
+                       }
+
+                       foreach ($terms as $term) {
+                               $profile = APContact::getByURL($term['url'], false);
+                               if (!empty($profile) && empty($contacts[$profile['url']])) {
+                                       $data['cc'][] = $profile['url'];
+                                       $contacts[$profile['url']] = $profile['url'];
+                               }
+                       }
+               } else {
+                       $receiver_list = Item::enumeratePermissions($item);
+
+                       $mentioned = [];
+
+                       foreach ($terms as $term) {
+                               $cid = Contact::getIdForURL($term['url'], $item['uid']);
+                               if (!empty($cid) && in_array($cid, $receiver_list)) {
+                                       $contact = DBA::selectFirst('contact', ['url'], ['id' => $cid, 'network' => Protocol::ACTIVITYPUB]);
+                                       $data['to'][] = $contact['url'];
+                                       $contacts[$contact['url']] = $contact['url'];
+                               }
+                       }
+
+                       foreach ($receiver_list as $receiver) {
+                               $contact = DBA::selectFirst('contact', ['url'], ['id' => $receiver, 'network' => Protocol::ACTIVITYPUB]);
+                               if (empty($contacts[$contact['url']])) {
+                                       $data['cc'][] = $contact['url'];
+                                       $contacts[$contact['url']] = $contact['url'];
+                               }
+                       }
+               }
+
+               $parents = Item::select(['id', 'author-link', 'owner-link', 'gravity'], ['parent' => $item['parent']]);
+               while ($parent = Item::fetch($parents)) {
+                       // Don't include data from future posts
+                       if ($parent['id'] >= $item['id']) {
+                               continue;
+                       }
+
+                       $profile = APContact::getByURL($parent['author-link'], false);
+                       if (!empty($profile) && empty($contacts[$profile['url']])) {
+                               $data['cc'][] = $profile['url'];
+                               $contacts[$profile['url']] = $profile['url'];
+                       }
+
+                       if ($item['gravity'] != GRAVITY_PARENT) {
+                               continue;
+                       }
+
+                       $profile = APContact::getByURL($parent['owner-link'], false);
+                       if (!empty($profile) && empty($contacts[$profile['url']])) {
+                               $data['cc'][] = $profile['url'];
+                               $contacts[$profile['url']] = $profile['url'];
+                       }
+               }
+               DBA::close($parents);
+
+               if (empty($data['to'])) {
+                       $data['to'] = $data['cc'];
+                       $data['cc'] = [];
+               }
+
+               return $data;
+       }
+
+       /**
+        * @brief Fetches a list of inboxes of followers of a given user
+        *
+        * @param integer $uid User ID
+        *
+        * @return array of follower inboxes
+        */
+       public static function fetchTargetInboxesforUser($uid)
+       {
+               $inboxes = [];
+
+               $condition = ['uid' => $uid, 'network' => Protocol::ACTIVITYPUB, 'archive' => false, 'pending' => false];
+
+               if (!empty($uid)) {
+                       $condition['rel'] = [Contact::FOLLOWER, Contact::FRIEND];
+               }
+
+               $contacts = DBA::select('contact', ['notify', 'batch'], $condition);
+               while ($contact = DBA::fetch($contacts)) {
+                       $contact = defaults($contact, 'batch', $contact['notify']);
+                       $inboxes[$contact] = $contact;
+               }
+               DBA::close($contacts);
+
+               return $inboxes;
+       }
+
+       /**
+        * @brief Fetches an array of inboxes for the given item and user
+        *
+        * @param array $item
+        * @param integer $uid User ID
+        *
+        * @return array with inboxes
+        */
+       public static function fetchTargetInboxes($item, $uid)
+       {
+               $permissions = self::createPermissionBlockForItem($item);
+               if (empty($permissions)) {
+                       return [];
+               }
+
+               $inboxes = [];
+
+               if ($item['gravity'] == GRAVITY_ACTIVITY) {
+                       $item_profile = APContact::getByURL($item['author-link']);
+               } else {
+                       $item_profile = APContact::getByURL($item['owner-link']);
+               }
+
+               foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
+                       if (empty($permissions[$element])) {
+                               continue;
+                       }
+
+                       foreach ($permissions[$element] as $receiver) {
+                               if ($receiver == $item_profile['followers']) {
+                                       $inboxes = self::fetchTargetInboxesforUser($uid);
+                               } else {
+                                       $profile = APContact::getByURL($receiver);
+                                       if (!empty($profile)) {
+                                               $target = defaults($profile, 'sharedinbox', $profile['inbox']);
+                                               $inboxes[$target] = $target;
+                                       }
+                               }
+                       }
+               }
+
+               return $inboxes;
+       }
+
+       /**
+        * @brief Returns the activity type of a given item
+        *
+        * @param array $item
+        *
+        * @return activity type
+        */
+       public static function getTypeOfItem($item)
+       {
+               if ($item['verb'] == ACTIVITY_POST) {
+                       if ($item['created'] == $item['edited']) {
+                               $type = 'Create';
+                       } else {
+                               $type = 'Update';
+                       }
+               } elseif ($item['verb'] == ACTIVITY_LIKE) {
+                       $type = 'Like';
+               } elseif ($item['verb'] == ACTIVITY_DISLIKE) {
+                       $type = 'Dislike';
+               } elseif ($item['verb'] == ACTIVITY_ATTEND) {
+                       $type = 'Accept';
+               } elseif ($item['verb'] == ACTIVITY_ATTENDNO) {
+                       $type = 'Reject';
+               } elseif ($item['verb'] == ACTIVITY_ATTENDMAYBE) {
+                       $type = 'TentativeAccept';
+               } else {
+                       $type = '';
+               }
+
+               return $type;
+       }
+
+       /**
+        * @brief Creates an activity array for a given item id
+        *
+        * @param integer $item_id
+        * @param boolean $object_mode Is the activity item is used inside another object?
+        *
+        * @return array of activity
+        */
+       public static function createActivityFromItem($item_id, $object_mode = false)
+       {
+               $item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
+
+               if (!DBA::isResult($item)) {
+                       return false;
+               }
+
+               $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
+               $conversation = DBA::selectFirst('conversation', ['source'], $condition);
+               if (DBA::isResult($conversation)) {
+                       $data = json_decode($conversation['source']);
+                       if (!empty($data)) {
+                               return $data;
+                       }
+               }
+
+               $type = self::getTypeOfItem($item);
+
+               if (!$object_mode) {
+                       $data = ['@context' => self::CONTEXT];
+
+                       if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
+                               $type = 'Undo';
+                       } elseif ($item['deleted']) {
+                               $type = 'Delete';
+                       }
+               } else {
+                       $data = [];
+               }
+
+               $data['id'] = $item['uri'] . '#' . $type;
+               $data['type'] = $type;
+               $data['actor'] = $item['author-link'];
+
+               $data['published'] = DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM);
+
+               if ($item["created"] != $item["edited"]) {
+                       $data['updated'] = DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM);
+               }
+
+               $data['context'] = self::fetchContextURLForItem($item);
+
+               $data = array_merge($data, ActivityPub::createPermissionBlockForItem($item));
+
+               if (in_array($data['type'], ['Create', 'Update', 'Announce', 'Delete'])) {
+                       $data['object'] = self::createNote($item);
+               } elseif ($data['type'] == 'Undo') {
+                       $data['object'] = self::createActivityFromItem($item_id, true);
+               } else {
+                       $data['object'] = $item['thr-parent'];
+               }
+
+               $owner = User::getOwnerDataById($item['uid']);
+
+               if (!$object_mode) {
+                       return LDSignature::sign($data, $owner);
+               } else {
+                       return $data;
+               }
+       }
+
+       /**
+        * @brief Creates an object array for a given item id
+        *
+        * @param integer $item_id
+        *
+        * @return object array
+        */
+       public static function createObjectFromItemID($item_id)
+       {
+               $item = Item::selectFirst([], ['id' => $item_id, 'parent-network' => Protocol::NATIVE_SUPPORT]);
+
+               if (!DBA::isResult($item)) {
+                       return false;
+               }
+
+               $data = ['@context' => self::CONTEXT];
+               $data = array_merge($data, self::createNote($item));
+
+               return $data;
+       }
+
+       /**
+        * @brief Returns a tag array for a given item array
+        *
+        * @param array $item
+        *
+        * @return array of tags
+        */
+       private static function createTagList($item)
+       {
+               $tags = [];
+
+               $terms = Term::tagArrayFromItemId($item['id'], TERM_MENTION);
+               foreach ($terms as $term) {
+                       $contact = Contact::getDetailsByURL($term['url']);
+                       if (!empty($contact['addr'])) {
+                               $mention = '@' . $contact['addr'];
+                       } else {
+                               $mention = '@' . $term['url'];
+                       }
+
+                       $tags[] = ['type' => 'Mention', 'href' => $term['url'], 'name' => $mention];
+               }
+               return $tags;
+       }
+
+       /**
+        * @brief Fetches the "context" value for a givem item array from the "conversation" table
+        *
+        * @param array $item
+        *
+        * @return string with context url
+        */
+       private static function fetchContextURLForItem($item)
+       {
+               $conversation = DBA::selectFirst('conversation', ['conversation-href', 'conversation-uri'], ['item-uri' => $item['parent-uri']]);
+               if (DBA::isResult($conversation) && !empty($conversation['conversation-href'])) {
+                       $context_uri = $conversation['conversation-href'];
+               } elseif (DBA::isResult($conversation) && !empty($conversation['conversation-uri'])) {
+                       $context_uri = $conversation['conversation-uri'];
+               } else {
+                       $context_uri = str_replace('/object/', '/context/', $item['parent-uri']);
+               }
+               return $context_uri;
+       }
+
+       /**
+        * @brief Creates a note/article object array
+        *
+        * @param array $item
+        *
+        * @return object array
+        */
+       private static function createNote($item)
+       {
+               if (!empty($item['title'])) {
+                       $type = 'Article';
+               } else {
+                       $type = 'Note';
+               }
+
+               if ($item['deleted']) {
+                       $type = 'Tombstone';
+               }
+
+               $data = [];
+               $data['id'] = $item['uri'];
+               $data['type'] = $type;
+
+               if ($item['deleted']) {
+                       return $data;
+               }
+
+               $data['summary'] = null; // Ignore by now
+
+               if ($item['uri'] != $item['thr-parent']) {
+                       $data['inReplyTo'] = $item['thr-parent'];
+               } else {
+                       $data['inReplyTo'] = null;
+               }
+
+               $data['diaspora:guid'] = $item['guid'];
+               $data['published'] = DateTimeFormat::utc($item["created"]."+00:00", DateTimeFormat::ATOM);
+
+               if ($item["created"] != $item["edited"]) {
+                       $data['updated'] = DateTimeFormat::utc($item["edited"]."+00:00", DateTimeFormat::ATOM);
+               }
+
+               $data['url'] = $item['plink'];
+               $data['attributedTo'] = $item['author-link'];
+               $data['actor'] = $item['author-link'];
+               $data['sensitive'] = false; // - Query NSFW
+               $data['context'] = self::fetchContextURLForItem($item);
+
+               if (!empty($item['title'])) {
+                       $data['name'] = BBCode::convert($item['title'], false, 7);
+               }
+
+               $data['content'] = BBCode::convert($item['body'], false, 7);
+               $data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"];
+
+               if (!empty($item['signed_text']) && ($item['uri'] != $item['thr-parent'])) {
+                       $data['diaspora:comment'] = $item['signed_text'];
+               }
+
+               $data['attachment'] = []; // @ToDo
+               $data['tag'] = self::createTagList($item);
+               $data = array_merge($data, ActivityPub::createPermissionBlockForItem($item));
+
+               return $data;
+       }
+
+       /**
+        * @brief Transmits a profile deletion to a given inbox
+        *
+        * @param integer $uid User ID
+        * @param string $inbox Target inbox
+        */
+       public static function transmitProfileDeletion($uid, $inbox)
+       {
+               $owner = User::getOwnerDataById($uid);
+               $profile = APContact::getByURL($owner['url']);
+
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => System::baseUrl() . '/activity/' . System::createGUID(),
+                       'type' => 'Delete',
+                       'actor' => $owner['url'],
+                       'object' => self::profile($uid),
+                       'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+                       'to' => [self::PUBLIC_COLLECTION],
+                       'cc' => []];
+
+               $signed = LDSignature::sign($data, $owner);
+
+               logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+               HTTPSignature::transmit($signed, $inbox, $uid);
+       }
+
+       /**
+        * @brief Transmits a profile change to a given inbox
+        *
+        * @param integer $uid User ID
+        * @param string $inbox Target inbox
+        */
+       public static function transmitProfileUpdate($uid, $inbox)
+       {
+               $owner = User::getOwnerDataById($uid);
+               $profile = APContact::getByURL($owner['url']);
+
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => System::baseUrl() . '/activity/' . System::createGUID(),
+                       'type' => 'Update',
+                       'actor' => $owner['url'],
+                       'object' => self::profile($uid),
+                       'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+                       'to' => [$profile['followers']],
+                       'cc' => []];
+
+               $signed = LDSignature::sign($data, $owner);
+
+               logger('Deliver profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+               HTTPSignature::transmit($signed, $inbox, $uid);
+       }
+
+       /**
+        * @brief Transmits a given activity to a target
+        *
+        * @param array $activity
+        * @param string $target Target profile
+        * @param integer $uid User ID
+        */
+       public static function transmitActivity($activity, $target, $uid)
+       {
+               $profile = APContact::getByURL($target);
+
+               $owner = User::getOwnerDataById($uid);
+
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => System::baseUrl() . '/activity/' . System::createGUID(),
+                       'type' => $activity,
+                       'actor' => $owner['url'],
+                       'object' => $profile['url'],
+                       'to' => $profile['url']];
+
+               logger('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid, LOGGER_DEBUG);
+
+               $signed = LDSignature::sign($data, $owner);
+               HTTPSignature::transmit($signed, $profile['inbox'], $uid);
+       }
+
+       /**
+        * @brief Transmit a message that the contact request had been accepted
+        *
+        * @param string $target Target profile
+        * @param $id
+        * @param integer $uid User ID
+        */
+       public static function transmitContactAccept($target, $id, $uid)
+       {
+               $profile = APContact::getByURL($target);
+
+               $owner = User::getOwnerDataById($uid);
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => System::baseUrl() . '/activity/' . System::createGUID(),
+                       'type' => 'Accept',
+                       'actor' => $owner['url'],
+                       'object' => ['id' => $id, 'type' => 'Follow',
+                               'actor' => $profile['url'],
+                               'object' => $owner['url']],
+                       'to' => $profile['url']];
+
+               logger('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+
+               $signed = LDSignature::sign($data, $owner);
+               HTTPSignature::transmit($signed, $profile['inbox'], $uid);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param string $target Target profile
+        * @param $id
+        * @param integer $uid User ID
+        */
+       public static function transmitContactReject($target, $id, $uid)
+       {
+               $profile = APContact::getByURL($target);
+
+               $owner = User::getOwnerDataById($uid);
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => System::baseUrl() . '/activity/' . System::createGUID(),
+                       'type' => 'Reject',
+                       'actor' => $owner['url'],
+                       'object' => ['id' => $id, 'type' => 'Follow',
+                               'actor' => $profile['url'],
+                               'object' => $owner['url']],
+                       'to' => $profile['url']];
+
+               logger('Sending reject to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+
+               $signed = LDSignature::sign($data, $owner);
+               HTTPSignature::transmit($signed, $profile['inbox'], $uid);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param string $target Target profile
+        * @param integer $uid User ID
+        */
+       public static function transmitContactUndo($target, $uid)
+       {
+               $profile = APContact::getByURL($target);
+
+               $id = System::baseUrl() . '/activity/' . System::createGUID();
+
+               $owner = User::getOwnerDataById($uid);
+               $data = ['@context' => 'https://www.w3.org/ns/activitystreams',
+                       'id' => $id,
+                       'type' => 'Undo',
+                       'actor' => $owner['url'],
+                       'object' => ['id' => $id, 'type' => 'Follow',
+                               'actor' => $owner['url'],
+                               'object' => $profile['url']],
+                       'to' => $profile['url']];
+
+               logger('Sending undo to ' . $target . ' for user ' . $uid . ' with id ' . $id, LOGGER_DEBUG);
+
+               $signed = LDSignature::sign($data, $owner);
+               HTTPSignature::transmit($signed, $profile['inbox'], $uid);
+       }
+
+       /**
+        * Fetches ActivityPub content from the given url
+        *
+        * @param string $url content url
+        * @return array
+        */
+       public static function fetchContent($url)
+       {
+               $ret = Network::curl($url, false, $redirects, ['accept_content' => 'application/activity+json, application/ld+json']);
+               if (!$ret['success'] || empty($ret['body'])) {
+                       return false;
+               }
+
+               return json_decode($ret['body'], true);
+       }
+
+       /**
+        * Fetches a profile from the given url into an array that is compatible to Probe::uri
+        *
+        * @param string $url profile url
+        * @return array
+        */
+       public static function probeProfile($url)
+       {
+               $apcontact = APContact::getByURL($url, true);
+               if (empty($apcontact)) {
+                       return false;
+               }
+
+               $profile = ['network' => Protocol::ACTIVITYPUB];
+               $profile['nick'] = $apcontact['nick'];
+               $profile['name'] = $apcontact['name'];
+               $profile['guid'] = $apcontact['uuid'];
+               $profile['url'] = $apcontact['url'];
+               $profile['addr'] = $apcontact['addr'];
+               $profile['alias'] = $apcontact['alias'];
+               $profile['photo'] = $apcontact['photo'];
+               // $profile['community']
+               // $profile['keywords']
+               // $profile['location']
+               $profile['about'] = $apcontact['about'];
+               $profile['batch'] = $apcontact['sharedinbox'];
+               $profile['notify'] = $apcontact['inbox'];
+               $profile['poll'] = $apcontact['outbox'];
+               $profile['pubkey'] = $apcontact['pubkey'];
+               $profile['baseurl'] = $apcontact['baseurl'];
+
+               // Remove all "null" fields
+               foreach ($profile as $field => $content) {
+                       if (is_null($content)) {
+                               unset($profile[$field]);
+                       }
+               }
+
+               return $profile;
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $body
+        * @param $header
+        * @param integer $uid User ID
+        */
+       public static function processInbox($body, $header, $uid)
+       {
+               $http_signer = HTTPSignature::getSigner($body, $header);
+               if (empty($http_signer)) {
+                       logger('Invalid HTTP signature, message will be discarded.', LOGGER_DEBUG);
+                       return;
+               } else {
+                       logger('HTTP signature is signed by ' . $http_signer, LOGGER_DEBUG);
+               }
+
+               $activity = json_decode($body, true);
+
+               $actor = JsonLD::fetchElement($activity, 'actor', 'id');
+               logger('Message for user ' . $uid . ' is from actor ' . $actor, LOGGER_DEBUG);
+
+               if (empty($activity)) {
+                       logger('Invalid body.', LOGGER_DEBUG);
+                       return;
+               }
+
+               if (LDSignature::isSigned($activity)) {
+                       $ld_signer = LDSignature::getSigner($activity);
+                       if (empty($ld_signer)) {
+                               logger('Invalid JSON-LD signature from ' . $actor, LOGGER_DEBUG);
+                       }
+                       if (!empty($ld_signer && ($actor == $http_signer))) {
+                               logger('The HTTP and the JSON-LD signature belong to ' . $ld_signer, LOGGER_DEBUG);
+                               $trust_source = true;
+                       } elseif (!empty($ld_signer)) {
+                               logger('JSON-LD signature is signed by ' . $ld_signer, LOGGER_DEBUG);
+                               $trust_source = true;
+                       } elseif ($actor == $http_signer) {
+                               logger('Bad JSON-LD signature, but HTTP signer fits the actor.', LOGGER_DEBUG);
+                               $trust_source = true;
+                       } else {
+                               logger('Invalid JSON-LD signature and the HTTP signer is different.', LOGGER_DEBUG);
+                               $trust_source = false;
+                       }
+               } elseif ($actor == $http_signer) {
+                       logger('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', LOGGER_DEBUG);
+                       $trust_source = true;
+               } else {
+                       logger('No JSON-LD signature, different actor.', LOGGER_DEBUG);
+                       $trust_source = false;
+               }
+
+               self::processActivity($activity, $body, $uid, $trust_source);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $url
+        * @param integer $uid User ID
+        */
+       public static function fetchOutbox($url, $uid)
+       {
+               $data = self::fetchContent($url);
+               if (empty($data)) {
+                       return;
+               }
+
+               if (!empty($data['orderedItems'])) {
+                       $items = $data['orderedItems'];
+               } elseif (!empty($data['first']['orderedItems'])) {
+                       $items = $data['first']['orderedItems'];
+               } elseif (!empty($data['first'])) {
+                       self::fetchOutbox($data['first'], $uid);
+                       return;
+               } else {
+                       $items = [];
+               }
+
+               foreach ($items as $activity) {
+                       self::processActivity($activity, '', $uid, true);
+               }
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param integer $uid User ID
+        * @param $trust_source
+        *
+        * @return 
+        */
+       private static function prepareObjectData($activity, $uid, &$trust_source)
+       {
+               $actor = JsonLD::fetchElement($activity, 'actor', 'id');
+               if (empty($actor)) {
+                       logger('Empty actor', LOGGER_DEBUG);
+                       return [];
+               }
+
+               // Fetch all receivers from to, cc, bto and bcc
+               $receivers = self::getReceivers($activity, $actor);
+
+               // When it is a delivery to a personal inbox we add that user to the receivers
+               if (!empty($uid)) {
+                       $owner = User::getOwnerDataById($uid);
+                       $additional = ['uid:' . $uid => $uid];
+                       $receivers = array_merge($receivers, $additional);
+               }
+
+               logger('Receivers: ' . json_encode($receivers), LOGGER_DEBUG);
+
+               $object_id = JsonLD::fetchElement($activity, 'object', 'id');
+               if (empty($object_id)) {
+                       logger('No object found', LOGGER_DEBUG);
+                       return [];
+               }
+
+               // Fetch the content only on activities where this matters
+               if (in_array($activity['type'], ['Create', 'Announce'])) {
+                       $object_data = self::fetchObject($object_id, $activity['object'], $trust_source);
+                       if (empty($object_data)) {
+                               logger("Object data couldn't be processed", LOGGER_DEBUG);
+                               return [];
+                       }
+                       // We had been able to retrieve the object data - so we can trust the source
+                       $trust_source = true;
+               } elseif (in_array($activity['type'], ['Like', 'Dislike'])) {
+                       // Create a mostly empty array out of the activity data (instead of the object).
+                       // This way we later don't have to check for the existence of ech individual array element.
+                       $object_data = self::processObject($activity);
+                       $object_data['name'] = $activity['type'];
+                       $object_data['author'] = $activity['actor'];
+                       $object_data['object'] = $object_id;
+                       $object_data['object_type'] = ''; // Since we don't fetch the object, we don't know the type
+               } else {
+                       $object_data = [];
+                       $object_data['id'] = $activity['id'];
+                       $object_data['object'] = $activity['object'];
+                       $object_data['object_type'] = JsonLD::fetchElement($activity, 'object', 'type');
+               }
+
+               $object_data = self::addActivityFields($object_data, $activity);
+
+               $object_data['type'] = $activity['type'];
+               $object_data['owner'] = $actor;
+               $object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers);
+
+               logger('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], LOGGER_DEBUG);
+
+               return $object_data;
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param $body
+        * @param integer $uid User ID
+        * @param $trust_source
+        */
+       private static function processActivity($activity, $body = '', $uid = null, $trust_source = false)
+       {
+               if (empty($activity['type'])) {
+                       logger('Empty type', LOGGER_DEBUG);
+                       return;
+               }
+
+               if (empty($activity['object'])) {
+                       logger('Empty object', LOGGER_DEBUG);
+                       return;
+               }
+
+               if (empty($activity['actor'])) {
+                       logger('Empty actor', LOGGER_DEBUG);
+                       return;
+
+               }
+
+               // $trust_source is called by reference and is set to true if the content was retrieved successfully
+               $object_data = self::prepareObjectData($activity, $uid, $trust_source);
+               if (empty($object_data)) {
+                       logger('No object data found', LOGGER_DEBUG);
+                       return;
+               }
+
+               if (!$trust_source) {
+                       logger('No trust for activity type "' . $activity['type'] . '", so we quit now.', LOGGER_DEBUG);
+               }
+
+               switch ($activity['type']) {
+                       case 'Create':
+                       case 'Announce':
+                               self::createItem($object_data, $body);
+                               break;
+
+                       case 'Like':
+                               self::likeItem($object_data, $body);
+                               break;
+
+                       case 'Dislike':
+                               self::dislikeItem($object_data, $body);
+                               break;
+
+                       case 'Update':
+                               if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
+                                       /// @todo
+                               } elseif (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
+                                       self::updatePerson($object_data, $body);
+                               }
+                               break;
+
+                       case 'Delete':
+                               if ($object_data['object_type'] == 'Tombstone') {
+                                       self::deleteItem($object_data, $body);
+                               } elseif (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
+                                       self::deletePerson($object_data, $body);
+                               }
+                               break;
+
+                       case 'Follow':
+                               self::followUser($object_data);
+                               break;
+
+                       case 'Accept':
+                               if ($object_data['object_type'] == 'Follow') {
+                                       self::acceptFollowUser($object_data);
+                               }
+                               break;
+
+                       case 'Reject':
+                               if ($object_data['object_type'] == 'Follow') {
+                                       self::rejectFollowUser($object_data);
+                               }
+                               break;
+
+                       case 'Undo':
+                               if ($object_data['object_type'] == 'Follow') {
+                                       self::undoFollowUser($object_data);
+                               } elseif (in_array($object_data['object_type'], self::ACTIVITY_TYPES)) {
+                                       self::undoActivity($object_data);
+                               }
+                               break;
+
+                       default:
+                               logger('Unknown activity: ' . $activity['type'], LOGGER_DEBUG);
+                               break;
+               }
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param $actor
+        *
+        * @return 
+        */
+       private static function getReceivers($activity, $actor)
+       {
+               $receivers = [];
+
+               // When it is an answer, we inherite the receivers from the parent
+               $replyto = JsonLD::fetchElement($activity, 'inReplyTo', 'id');
+               if (!empty($replyto)) {
+                       $parents = Item::select(['uid'], ['uri' => $replyto]);
+                       while ($parent = Item::fetch($parents)) {
+                               $receivers['uid:' . $parent['uid']] = $parent['uid'];
+                       }
+               }
+
+               if (!empty($actor)) {
+                       $profile = APContact::getByURL($actor);
+                       $followers = defaults($profile, 'followers', '');
+
+                       logger('Actor: ' . $actor . ' - Followers: ' . $followers, LOGGER_DEBUG);
+               } else {
+                       logger('Empty actor', LOGGER_DEBUG);
+                       $followers = '';
+               }
+
+               foreach (['to', 'cc', 'bto', 'bcc'] as $element) {
+                       if (empty($activity[$element])) {
+                               continue;
+                       }
+
+                       // The receiver can be an array or a string
+                       if (is_string($activity[$element])) {
+                               $activity[$element] = [$activity[$element]];
+                       }
+
+                       foreach ($activity[$element] as $receiver) {
+                               if ($receiver == self::PUBLIC_COLLECTION) {
+                                       $receivers['uid:0'] = 0;
+                               }
+
+                               if (($receiver == self::PUBLIC_COLLECTION) && !empty($actor)) {
+                                       // This will most likely catch all OStatus connections to Mastodon
+                                       $condition = ['alias' => [$actor, normalise_link($actor)], 'rel' => [Contact::SHARING, Contact::FRIEND]
+                                               , 'archive' => false, 'pending' => false];
+                                       $contacts = DBA::select('contact', ['uid'], $condition);
+                                       while ($contact = DBA::fetch($contacts)) {
+                                               if ($contact['uid'] != 0) {
+                                                       $receivers['uid:' . $contact['uid']] = $contact['uid'];
+                                               }
+                                       }
+                                       DBA::close($contacts);
+                               }
+
+                               if (in_array($receiver, [$followers, self::PUBLIC_COLLECTION]) && !empty($actor)) {
+                                       $condition = ['nurl' => normalise_link($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
+                                               'network' => Protocol::ACTIVITYPUB, 'archive' => false, 'pending' => false];
+                                       $contacts = DBA::select('contact', ['uid'], $condition);
+                                       while ($contact = DBA::fetch($contacts)) {
+                                               if ($contact['uid'] != 0) {
+                                                       $receivers['uid:' . $contact['uid']] = $contact['uid'];
+                                               }
+                                       }
+                                       DBA::close($contacts);
+                                       continue;
+                               }
+
+                               $condition = ['self' => true, 'nurl' => normalise_link($receiver)];
+                               $contact = DBA::selectFirst('contact', ['uid'], $condition);
+                               if (!DBA::isResult($contact)) {
+                                       continue;
+                               }
+                               $receivers['uid:' . $contact['uid']] = $contact['uid'];
+                       }
+               }
+
+               self::switchContacts($receivers, $actor);
+
+               return $receivers;
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $cid
+        * @param integer $uid User ID
+        * @param $url
+        */
+       private static function switchContact($cid, $uid, $url)
+       {
+               $profile = ActivityPub::probeProfile($url);
+               if (empty($profile)) {
+                       return;
+               }
+
+               logger('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' from OStatus to ActivityPub');
+
+               $photo = $profile['photo'];
+               unset($profile['photo']);
+               unset($profile['baseurl']);
+
+               $profile['nurl'] = normalise_link($profile['url']);
+               DBA::update('contact', $profile, ['id' => $cid]);
+
+               Contact::updateAvatar($photo, $uid, $cid);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $receivers
+        * @param $actor
+        */
+       private static function switchContacts($receivers, $actor)
+       {
+               if (empty($actor)) {
+                       return;
+               }
+
+               foreach ($receivers as $receiver) {
+                       $contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'nurl' => normalise_link($actor)]);
+                       if (DBA::isResult($contact)) {
+                               self::switchContact($contact['id'], $receiver, $actor);
+                       }
+
+                       $contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'alias' => [normalise_link($actor), $actor]]);
+                       if (DBA::isResult($contact)) {
+                               self::switchContact($contact['id'], $receiver, $actor);
+                       }
+               }
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $object_data
+        * @param array $activity
+        *
+        * @return 
+        */
+       private static function addActivityFields($object_data, $activity)
+       {
+               if (!empty($activity['published']) && empty($object_data['published'])) {
+                       $object_data['published'] = $activity['published'];
+               }
+
+               if (!empty($activity['updated']) && empty($object_data['updated'])) {
+                       $object_data['updated'] = $activity['updated'];
+               }
+
+               if (!empty($activity['inReplyTo']) && empty($object_data['parent-uri'])) {
+                       $object_data['parent-uri'] = JsonLD::fetchElement($activity, 'inReplyTo', 'id');
+               }
+
+               if (!empty($activity['instrument'])) {
+                       $object_data['service'] = JsonLD::fetchElement($activity, 'instrument', 'name', 'type', 'Service');
+               }
+               return $object_data;
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $object_id
+        * @param $object
+        * @param $trust_source
+        *
+        * @return 
+        */
+       private static function fetchObject($object_id, $object = [], $trust_source = false)
+       {
+               if (!$trust_source || is_string($object)) {
+                       $data = self::fetchContent($object_id);
+                       if (empty($data)) {
+                               logger('Empty content for ' . $object_id . ', check if content is available locally.', LOGGER_DEBUG);
+                               $data = $object_id;
+                       } else {
+                               logger('Fetched content for ' . $object_id, LOGGER_DEBUG);
+                       }
+               } else {
+                       logger('Using original object for url ' . $object_id, LOGGER_DEBUG);
+                       $data = $object;
+               }
+
+               if (is_string($data)) {
+                       $item = Item::selectFirst([], ['uri' => $data]);
+                       if (!DBA::isResult($item)) {
+                               logger('Object with url ' . $data . ' was not found locally.', LOGGER_DEBUG);
+                               return false;
+                       }
+                       logger('Using already stored item for url ' . $object_id, LOGGER_DEBUG);
+                       $data = self::createNote($item);
+               }
+
+               if (empty($data['type'])) {
+                       logger('Empty type', LOGGER_DEBUG);
+                       return false;
+               }
+
+               if (in_array($data['type'], self::CONTENT_TYPES)) {
+                       return self::processObject($data);
+               }
+
+               if ($data['type'] == 'Announce') {
+                       if (empty($data['object'])) {
+                               return false;
+                       }
+                       return self::fetchObject($data['object']);
+               }
+
+               logger('Unhandled object type: ' . $data['type'], LOGGER_DEBUG);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $object
+        *
+        * @return 
+        */
+       private static function processObject($object)
+       {
+               if (empty($object['id'])) {
+                       return false;
+               }
+
+               $object_data = [];
+               $object_data['object_type'] = $object['type'];
+               $object_data['id'] = $object['id'];
+
+               if (!empty($object['inReplyTo'])) {
+                       $object_data['reply-to-id'] = JsonLD::fetchElement($object, 'inReplyTo', 'id');
+               } else {
+                       $object_data['reply-to-id'] = $object_data['id'];
+               }
+
+               $object_data['published'] = defaults($object, 'published', null);
+               $object_data['updated'] = defaults($object, 'updated', $object_data['published']);
+
+               if (empty($object_data['published']) && !empty($object_data['updated'])) {
+                       $object_data['published'] = $object_data['updated'];
+               }
+
+               $actor = JsonLD::fetchElement($object, 'attributedTo', 'id');
+               if (empty($actor)) {
+                       $actor = defaults($object, 'actor', null);
+               }
+
+               $object_data['diaspora:guid'] = defaults($object, 'diaspora:guid', null);
+               $object_data['owner'] = $object_data['author'] = $actor;
+               $object_data['context'] = defaults($object, 'context', null);
+               $object_data['conversation'] = defaults($object, 'conversation', null);
+               $object_data['sensitive'] = defaults($object, 'sensitive', null);
+               $object_data['name'] = defaults($object, 'title', null);
+               $object_data['name'] = defaults($object, 'name', $object_data['name']);
+               $object_data['summary'] = defaults($object, 'summary', null);
+               $object_data['content'] = defaults($object, 'content', null);
+               $object_data['source'] = defaults($object, 'source', null);
+               $object_data['location'] = JsonLD::fetchElement($object, 'location', 'name', 'type', 'Place');
+               $object_data['attachments'] = defaults($object, 'attachment', null);
+               $object_data['tags'] = defaults($object, 'tag', null);
+               $object_data['service'] = JsonLD::fetchElement($object, 'instrument', 'name', 'type', 'Service');
+               $object_data['alternate-url'] = JsonLD::fetchElement($object, 'url', 'href');
+               $object_data['receiver'] = self::getReceivers($object, $object_data['owner']);
+
+               // Common object data:
+
+               // Unhandled
+               // @context, type, actor, signature, mediaType, duration, replies, icon
+
+               // Also missing: (Defined in the standard, but currently unused)
+               // audience, preview, endTime, startTime, generator, image
+
+               // Data in Notes:
+
+               // Unhandled
+               // contentMap, announcement_count, announcements, context_id, likes, like_count
+               // inReplyToStatusId, shares, quoteUrl, statusnetConversationId
+
+               // Data in video:
+
+               // To-Do?
+               // category, licence, language, commentsEnabled
+
+               // Unhandled
+               // views, waitTranscoding, state, support, subtitleLanguage
+               // likes, dislikes, shares, comments
+
+               return $object_data;
+       }
+
+       /**
+        * @brief Converts mentions from Pleroma into the Friendica format
+        *
+        * @param string $body
+        *
+        * @return converted body
+        */
+       private static function convertMentions($body)
+       {
+               $URLSearchString = "^\[\]";
+               $body = preg_replace("/\[url\=([$URLSearchString]*)\]([#@!])(.*?)\[\/url\]/ism", '$2[url=$1]$3[/url]', $body);
+
+               return $body;
+       }
+
+       /**
+        * @brief Constructs a string with tags for a given tag array
+        *
+        * @param array $tags
+        * @param boolean $sensitive
+        *
+        * @return string with tags
+        */
+       private static function constructTagList($tags, $sensitive)
+       {
+               if (empty($tags)) {
+                       return '';
+               }
+
+               $tag_text = '';
+               foreach ($tags as $tag) {
+                       if (in_array($tag['type'], ['Mention', 'Hashtag'])) {
+                               if (!empty($tag_text)) {
+                                       $tag_text .= ',';
+                               }
+
+                               $tag_text .= substr($tag['name'], 0, 1) . '[url=' . $tag['href'] . ']' . substr($tag['name'], 1) . '[/url]';
+                       }
+               }
+
+               /// @todo add nsfw for $sensitive
+
+               return $tag_text;
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $attachments
+        * @param array $item
+        *
+        * @return item array
+        */
+       private static function constructAttachList($attachments, $item)
+       {
+               if (empty($attachments)) {
+                       return $item;
+               }
+
+               foreach ($attachments as $attach) {
+                       $filetype = strtolower(substr($attach['mediaType'], 0, strpos($attach['mediaType'], '/')));
+                       if ($filetype == 'image') {
+                               $item['body'] .= "\n[img]".$attach['url'].'[/img]';
+                       } else {
+                               if (!empty($item["attach"])) {
+                                       $item["attach"] .= ',';
+                               } else {
+                                       $item["attach"] = '';
+                               }
+                               if (!isset($attach['length'])) {
+                                       $attach['length'] = "0";
+                               }
+                               $item["attach"] .= '[attach]href="'.$attach['url'].'" length="'.$attach['length'].'" type="'.$attach['mediaType'].'" title="'.defaults($attach, 'name', '').'"[/attach]';
+                       }
+               }
+
+               return $item;
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param $body
+        */
+       private static function createItem($activity, $body)
+       {
+               $item = [];
+               $item['verb'] = ACTIVITY_POST;
+               $item['parent-uri'] = $activity['reply-to-id'];
+
+               if ($activity['reply-to-id'] == $activity['id']) {
+                       $item['gravity'] = GRAVITY_PARENT;
+                       $item['object-type'] = ACTIVITY_OBJ_NOTE;
+               } else {
+                       $item['gravity'] = GRAVITY_COMMENT;
+                       $item['object-type'] = ACTIVITY_OBJ_COMMENT;
+               }
+
+               if (($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
+                       logger('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.');
+                       self::fetchMissingActivity($activity['reply-to-id'], $activity);
+               }
+
+               self::postItem($activity, $item, $body);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param $body
+        */
+       private static function likeItem($activity, $body)
+       {
+               $item = [];
+               $item['verb'] = ACTIVITY_LIKE;
+               $item['parent-uri'] = $activity['object'];
+               $item['gravity'] = GRAVITY_ACTIVITY;
+               $item['object-type'] = ACTIVITY_OBJ_NOTE;
+
+               self::postItem($activity, $item, $body);
+       }
+
+       /**
+        * @brief Delete items
+        *
+        * @param array $activity
+        * @param $body
+        */
+       private static function deleteItem($activity)
+       {
+               $owner = Contact::getIdForURL($activity['owner']);
+               $object = JsonLD::fetchElement($activity, 'object', 'id');
+               logger('Deleting item ' . $object . ' from ' . $owner, LOGGER_DEBUG);
+               Item::delete(['uri' => $object, 'owner-id' => $owner]);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param $body
+        */
+       private static function dislikeItem($activity, $body)
+       {
+               $item = [];
+               $item['verb'] = ACTIVITY_DISLIKE;
+               $item['parent-uri'] = $activity['object'];
+               $item['gravity'] = GRAVITY_ACTIVITY;
+               $item['object-type'] = ACTIVITY_OBJ_NOTE;
+
+               self::postItem($activity, $item, $body);
+       }
+
+       /**
+        * @brief 
+        *
+        * @param array $activity
+        * @param array $item
+        * @param $body
+        */
+       private static function postItem($activity, $item, $body)
+       {
+               /// @todo What to do with $activity['context']?
+
+               if (($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['parent-uri']])) {
+                       logger('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG);
+                       return;
+               }
+
+               $item['network'] = Protocol::ACTIVITYPUB;
+               $item['private'] = !in_array(0, $activity['receiver']);
+               $item['author-id'] = Contact::getIdForURL($activity['author'], 0, true);
+               $item['owner-id'] = Contact::getIdForURL($activity['owner'], 0, true);
+               $item['uri'] = $activity['id'];
+               $item['created'] = $activity['published'];
+               $item['edited'] = $activity['updated'];
+               $item['guid'] = $activity['diaspora:guid'];
+               $item['title'] = HTML::toBBCode($activity['name']);
+               $item['content-warning'] = HTML::toBBCode($activity['summary']);
+               $item['body'] = self::convertMentions(HTML::toBBCode($activity['content']));
+               $item['location'] = $activity['location'];
+               $item['tag'] = self::constructTagList($activity['tags'], $activity['sensitive']);
+               $item['app'] = $activity['service'];
+               $item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
+
+               $item = self::constructAttachList($activity['attachments'], $item);
+
+               $source = JsonLD::fetchElement($activity, 'source', 'content', 'mediaType', 'text/bbcode');
+               if (!empty($source)) {
+                       $item['body'] = $source;
+               }
+
+               $item['protocol'] = Conversation::PARCEL_ACTIVITYPUB;
+               $item['source'] = $body;
+               $item['conversation-href'] = $activity['context'];
+               $item['conversation-uri'] = $activity['conversation'];
+
+               foreach ($activity['receiver'] as $receiver) {
+                       $item['uid'] = $receiver;
+                       $item['contact-id'] = Contact::getIdForURL($activity['author'], $receiver, true);
+
+                       if (($receiver != 0) && empty($item['contact-id'])) {
+                               $item['contact-id'] = Contact::getIdForURL($activity['author'], 0, true);
+                       }
+
+                       $item_id = Item::insert($item);
+                       logger('Storing for user ' . $item['uid'] . ': ' . $item_id);
+               }
+       }
+
+       /**
+        * @brief 
+        *
+        * @param $url
+        * @param $child
+        */
+       private static function fetchMissingActivity($url, $child)
+       {
+               if (Config::get('system', 'ostatus_full_threads')) {
+                       return;
+               }
+
+               $object = ActivityPub::fetchContent($url);
+               if (empty($object)) {
+                       logger('Activity ' . $url . ' was not fetchable, aborting.');
+                       return;
+               }
+
+               $activity = [];
+               $activity['@context'] = $object['@context'];
+               unset($object['@context']);
+               $activity['id'] = $object['id'];
+               $activity['to'] = defaults($object, 'to', []);
+               $activity['cc'] = defaults($object, 'cc', []);
+               $activity['actor'] = $child['author'];
+               $activity['object'] = $object;
+               $activity['published'] = $object['published'];
+               $activity['type'] = 'Create';
+
+               self::processActivity($activity);
+               logger('Activity ' . $url . ' had been fetched and processed.');
+       }
+
+       /**
+        * @brief perform a "follow" request
+        *
+        * @param array $activity
+        */
+       private static function followUser($activity)
+       {
+               $actor = JsonLD::fetchElement($activity, 'object', 'id');
+               $uid = User::getIdForURL($actor);
+               if (empty($uid)) {
+                       return;
+               }
+
+               $owner = User::getOwnerDataById($uid);
+
+               $cid = Contact::getIdForURL($activity['owner'], $uid);
+               if (!empty($cid)) {
+                       $contact = DBA::selectFirst('contact', [], ['id' => $cid]);
+               } else {
+                       $contact = false;
+               }
+
+               $item = ['author-id' => Contact::getIdForURL($activity['owner']),
+                       'author-link' => $activity['owner']];
+
+               Contact::addRelationship($owner, $contact, $item);
+               $cid = Contact::getIdForURL($activity['owner'], $uid);
+               if (empty($cid)) {
+                       return;
+               }
+
+               $contact = DBA::selectFirst('contact', ['network'], ['id' => $cid]);
+               if ($contact['network'] != Protocol::ACTIVITYPUB) {
+                       Contact::updateFromProbe($cid, Protocol::ACTIVITYPUB);
+               }
+
+               DBA::update('contact', ['hub-verify' => $activity['id']], ['id' => $cid]);
+               logger('Follow user ' . $uid . ' from contact ' . $cid . ' with id ' . $activity['id']);
+       }
+
+       /**
+        * @brief Update the given profile
+        *
+        * @param array $activity
+        */
+       private static function updatePerson($activity)
+       {
+               if (empty($activity['object']['id'])) {
+                       return;
+               }
+
+               logger('Updating profile for ' . $activity['object']['id'], LOGGER_DEBUG);
+               APContact::getByURL($activity['object']['id'], true);
+       }
+
+       /**
+        * @brief Delete the given profile
+        *
+        * @param array $activity
+        */
+       private static function deletePerson($activity)
+       {
+               if (empty($activity['object']['id']) || empty($activity['object']['actor'])) {
+                       logger('Empty object id or actor.', LOGGER_DEBUG);
+                       return;
+               }
+
+               if ($activity['object']['id'] != $activity['object']['actor']) {
+                       logger('Object id does not match actor.', LOGGER_DEBUG);
+                       return;
+               }
+
+               $contacts = DBA::select('contact', ['id'], ['nurl' => normalise_link($activity['object']['id'])]);
+               while ($contact = DBA::fetch($contacts)) {
+                       Contact::remove($contact["id"]);
+               }
+               DBA::close($contacts);
+
+               logger('Deleted contact ' . $activity['object']['id'], LOGGER_DEBUG);
+       }
+
+       /**
+        * @brief Accept a follow request
+        *
+        * @param array $activity
+        */
+       private static function acceptFollowUser($activity)
+       {
+               $actor = JsonLD::fetchElement($activity, 'object', 'actor');
+               $uid = User::getIdForURL($actor);
+               if (empty($uid)) {
+                       return;
+               }
+
+               $owner = User::getOwnerDataById($uid);
+
+               $cid = Contact::getIdForURL($activity['owner'], $uid);
+               if (empty($cid)) {
+                       logger('No contact found for ' . $activity['owner'], LOGGER_DEBUG);
+                       return;
+               }
+
+               $fields = ['pending' => false];
+
+               $contact = DBA::selectFirst('contact', ['rel'], ['id' => $cid]);
+               if ($contact['rel'] == Contact::FOLLOWER) {
+                       $fields['rel'] = Contact::FRIEND;
+               }
+
+               $condition = ['id' => $cid];
+               DBA::update('contact', $fields, $condition);
+               logger('Accept contact request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
+       }
+
+       /**
+        * @brief Reject a follow request
+        *
+        * @param array $activity
+        */
+       private static function rejectFollowUser($activity)
+       {
+               $actor = JsonLD::fetchElement($activity, 'object', 'actor');
+               $uid = User::getIdForURL($actor);
+               if (empty($uid)) {
+                       return;
+               }
+
+               $owner = User::getOwnerDataById($uid);
+
+               $cid = Contact::getIdForURL($activity['owner'], $uid);
+               if (empty($cid)) {
+                       logger('No contact found for ' . $activity['owner'], LOGGER_DEBUG);
+                       return;
+               }
+
+               if (DBA::exists('contact', ['id' => $cid, 'rel' => Contact::SHARING, 'pending' => true])) {
+                       Contact::remove($cid);
+                       logger('Rejected contact request from contact ' . $cid . ' for user ' . $uid . ' - contact had been removed.', LOGGER_DEBUG);
+               } else {
+                       logger('Rejected contact request from contact ' . $cid . ' for user ' . $uid . '.', LOGGER_DEBUG);
+               }
+       }
+
+       /**
+        * @brief Undo activity like "like" or "dislike"
+        *
+        * @param array $activity
+        */
+       private static function undoActivity($activity)
+       {
+               $activity_url = JsonLD::fetchElement($activity, 'object', 'id');
+               if (empty($activity_url)) {
+                       return;
+               }
+
+               $actor = JsonLD::fetchElement($activity, 'object', 'actor');
+               if (empty($actor)) {
+                       return;
+               }
+
+               $author_id = Contact::getIdForURL($actor);
+               if (empty($author_id)) {
+                       return;
+               }
+
+               Item::delete(['uri' => $activity_url, 'author-id' => $author_id, 'gravity' => GRAVITY_ACTIVITY]);
+       }
+
+       /**
+        * @brief Activity to remove a follower
+        *
+        * @param array $activity
+        */
+       private static function undoFollowUser($activity)
+       {
+               $object = JsonLD::fetchElement($activity, 'object', 'object');
+               $uid = User::getIdForURL($object);
+               if (empty($uid)) {
+                       return;
+               }
+
+               $owner = User::getOwnerDataById($uid);
+
+               $cid = Contact::getIdForURL($activity['owner'], $uid);
+               if (empty($cid)) {
+                       logger('No contact found for ' . $activity['owner'], LOGGER_DEBUG);
+                       return;
+               }
+
+               $contact = DBA::selectFirst('contact', [], ['id' => $cid]);
+               if (!DBA::isResult($contact)) {
+                       return;
+               }
+
+               Contact::removeFollower($owner, $contact);
+               logger('Undo following request from contact ' . $cid . ' for user ' . $uid, LOGGER_DEBUG);
+       }
+}
index 27cfdccd853af83b89d026ddaf6fb5e741e25605..847809a36b716d96a17314f67a45f5bc3e03eef3 100644 (file)
@@ -1592,17 +1592,13 @@ class Diaspora
                if (DBA::isResult($item)) {
                        return $item["uri"];
                } elseif (!$onlyfound) {
-                       $contact = Contact::getDetailsByAddr($author, 0);
-                       if (!empty($contact['network'])) {
-                               $prefix = 'urn:X-' . $contact['network'] . ':';
-                       } else {
-                               // This fallback should happen most unlikely
-                               $prefix = 'urn:X-dspr:';
-                       }
+                       $person = self::personByHandle($author);
 
-                       $author_parts = explode('@', $author);
+                       $parts = parse_url($person['url']);
+                       unset($parts['path']);
+                       $host_url = Network::unparseURL($parts);
 
-                       return $prefix . $author_parts[1] . ':' . $author_parts[0] . ':'. $guid;
+                       return $host_url . '/object/' . $guid;
                }
 
                return "";
@@ -3204,7 +3200,7 @@ class Diaspora
                $author = self::myHandle($owner);
 
                $message = ["author" => $author,
-                               "guid" => System::createGUID(32),
+                               "guid" => System::createUUID(),
                                "parent_type" => "Post",
                                "parent_guid" => $item["guid"]];
 
index ece265c99b391dff3ba23c1c2f545cbebe281b58..2eb8c55390afd2bcb0e26ff30e719227a7c5edbf 100644 (file)
@@ -2004,8 +2004,7 @@ class OStatus
                }
 
                if (intval($item["parent"]) > 0) {
-                       $conversation_href = System::baseUrl()."/display/".$owner["nick"]."/".$item["parent"];
-                       $conversation_uri = $conversation_href;
+                       $conversation_href = $conversation_uri = str_replace('/object/', '/context/', $item['parent-uri']);
 
                        if (isset($parent_item)) {
                                $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
index 2939f69e55c2cbe42727cd76e7b41952df811bda..280dbe72c2a2afe151b5c5d47dd8e11a561fc182 100644 (file)
@@ -333,7 +333,7 @@ class PortableContact
                        $server_url = normalise_link(self::detectServer($profile));
                }
 
-               if (!in_array($gcontacts[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
+               if (!in_array($gcontacts[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::FEED, Protocol::OSTATUS, ""])) {
                        logger("Profile ".$profile.": Network type ".$gcontacts[0]["network"]." can't be checked", LOGGER_DEBUG);
                        return false;
                }
index 911de4308e5f7eb0b371f6c277f48d88386232e8..234d896078a6b1710df1885348ad25fdece2e610 100644 (file)
@@ -5,94 +5,64 @@
  */
 namespace Friendica\Util;
 
+use Friendica\BaseObject;
 use Friendica\Core\Config;
 use Friendica\Database\DBA;
+use Friendica\Model\User;
+use Friendica\Model\APContact;
+use Friendica\Protocol\ActivityPub;
 
 /**
  * @brief Implements HTTP Signatures per draft-cavage-http-signatures-07.
  *
  * Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Web/HTTPSig.php
  *
+ * Other parts of the code for HTTP signing are taken from the Osada project.
+ * https://framagit.org/macgirvin/osada
+ *
  * @see https://tools.ietf.org/html/draft-cavage-http-signatures-07
  */
 
 class HTTPSignature
 {
+       // See draft-cavage-http-signatures-08
        /**
-        * @brief RFC5843
-        *
-        * Disabled until Friendica's ActivityPub implementation
-        * is ready.
+        * @brief Verifies a magic request
         *
-        * @see https://tools.ietf.org/html/rfc5843
+        * @param $key
         *
-        * @param string  $body The value to create the digest for
-        * @param boolean $set  (optional, default true)
-        *   If set send a Digest HTTP header
-        *
-        * @return string The generated digest of $body
+        * @return array with verification data
         */
-//     public static function generateDigest($body, $set = true)
-//     {
-//             $digest = base64_encode(hash('sha256', $body, true));
-//
-//             if($set) {
-//                     header('Digest: SHA-256=' . $digest);
-//             }
-//             return $digest;
-//     }
-
-       // See draft-cavage-http-signatures-08
-       public static function verify($data, $key = '')
+       public static function verifyMagic($key)
        {
-               $body      = $data;
                $headers   = null;
                $spoofable = false;
                $result = [
                        'signer'         => '',
                        'header_signed'  => false,
-                       'header_valid'   => false,
-                       'content_signed' => false,
-                       'content_valid'  => false
+                       'header_valid'   => false
                ];
 
                // Decide if $data arrived via controller submission or curl.
-               if (is_array($data) && $data['header']) {
-                       if (!$data['success']) {
-                               return $result;
-                       }
+               $headers = [];
+               $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']).' '.$_SERVER['REQUEST_URI'];
 
-                       $h = new HTTPHeaders($data['header']);
-                       $headers = $h->fetch();
-                       $body = $data['body'];
-               } else {
-                       $headers = [];
-                       $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']).' '.$_SERVER['REQUEST_URI'];
-
-                       foreach ($_SERVER as $k => $v) {
-                               if (strpos($k, 'HTTP_') === 0) {
-                                       $field = str_replace('_', '-', strtolower(substr($k, 5)));
-                                       $headers[$field] = $v;
-                               }
+               foreach ($_SERVER as $k => $v) {
+                       if (strpos($k, 'HTTP_') === 0) {
+                               $field = str_replace('_', '-', strtolower(substr($k, 5)));
+                               $headers[$field] = $v;
                        }
                }
 
                $sig_block = null;
 
-               if (array_key_exists('signature', $headers)) {
-                       $sig_block = self::parseSigheader($headers['signature']);
-               } elseif (array_key_exists('authorization', $headers)) {
-                       $sig_block = self::parseSigheader($headers['authorization']);
-               }
+               $sig_block = self::parseSigheader($headers['authorization']);
 
                if (!$sig_block) {
                        logger('no signature provided.');
                        return $result;
                }
 
-               // Warning: This log statement includes binary data
-               // logger('sig_block: ' . print_r($sig_block,true), LOGGER_DATA);
-
                $result['header_signed'] = true;
 
                $signed_headers = $sig_block['headers'];
@@ -112,13 +82,7 @@ class HTTPSignature
 
                $signed_data = rtrim($signed_data, "\n");
 
-               $algorithm = null;
-               if ($sig_block['algorithm'] === 'rsa-sha256') {
-                       $algorithm = 'sha256';
-               }
-               if ($sig_block['algorithm'] === 'rsa-sha512') {
-                       $algorithm = 'sha512';
-               }
+               $algorithm = 'sha512';
 
                if ($key && function_exists($key)) {
                        $result['signer'] = $sig_block['keyId'];
@@ -127,12 +91,6 @@ class HTTPSignature
 
                logger('Got keyID ' . $sig_block['keyId']);
 
-               // We don't use Activity Pub at the moment.
-//             if (!$key) {
-//                     $result['signer'] = $sig_block['keyId'];
-//                     $key = self::getActivitypubKey($sig_block['keyId']);
-//             }
-
                if (!$key) {
                        return $result;
                }
@@ -149,130 +107,39 @@ class HTTPSignature
                        $result['header_valid'] = true;
                }
 
-               if (in_array('digest', $signed_headers)) {
-                       $result['content_signed'] = true;
-                       $digest = explode('=', $headers['digest']);
-
-                       if ($digest[0] === 'SHA-256') {
-                               $hashalg = 'sha256';
-                       }
-                       if ($digest[0] === 'SHA-512') {
-                               $hashalg = 'sha512';
-                       }
-
-                       // The explode operation will have stripped the '=' padding, so compare against unpadded base64.
-                       if (rtrim(base64_encode(hash($hashalg, $body, true)), '=') === $digest[1]) {
-                               $result['content_valid'] = true;
-                       }
-               }
-
-               logger('Content_Valid: ' . $result['content_valid']);
-
                return $result;
        }
 
-       /**
-        * Fetch the public key for Activity Pub contact.
-        *
-        * @param string|int The identifier (contact addr or contact ID).
-        * @return string|boolean The public key or false on failure.
-        */
-       private static function getActivitypubKey($id)
-       {
-               if (strpos($id, 'acct:') === 0) {
-                       $contact = DBA::selectFirst('contact', ['pubkey'], ['uid' => 0, 'addr' => str_replace('acct:', '', $id)]);
-               } else {
-                       $contact = DBA::selectFirst('contact', ['pubkey'], ['id' => $id, 'network' => 'activitypub']);
-               }
-
-               if (DBA::isResult($contact)) {
-                       return $contact['pubkey'];
-               }
-
-               if(function_exists('as_fetch')) {
-                       $r = as_fetch($id);
-               }
-
-               if ($r) {
-                       $j = json_decode($r, true);
-
-                       if (array_key_exists('publicKey', $j) && array_key_exists('publicKeyPem', $j['publicKey'])) {
-                               if ((array_key_exists('id', $j['publicKey']) && $j['publicKey']['id'] !== $id) && $j['id'] !== $id) {
-                                       return false;
-                               }
-
-                               return $j['publicKey']['publicKeyPem'];
-                       }
-               }
-
-               return false;
-       }
-
        /**
         * @brief
         *
-        * @param string  $request
         * @param array   $head
         * @param string  $prvkey
         * @param string  $keyid (optional, default 'Key')
-        * @param boolean $send_headers (optional, default false)
-        *   If set send a HTTP header
-        * @param boolean $auth (optional, default false)
-        * @param string  $alg (optional, default 'sha256')
-        * @param string  $crypt_key (optional, default null)
-        * @param string  $crypt_algo (optional, default 'aes256ctr')
         *
         * @return array
         */
-       public static function createSig($request, $head, $prvkey, $keyid = 'Key', $send_headers = false, $auth = false, $alg = 'sha256', $crypt_key = null, $crypt_algo = 'aes256ctr')
+       public static function createSig($head, $prvkey, $keyid = 'Key')
        {
                $return_headers = [];
 
-               if ($alg === 'sha256') {
-                       $algorithm = 'rsa-sha256';
-               }
-
-               if ($alg === 'sha512') {
-                       $algorithm = 'rsa-sha512';
-               }
+               $alg = 'sha512';
+               $algorithm = 'rsa-sha512';
 
-               $x = self::sign($request, $head, $prvkey, $alg);
+               $x = self::sign($head, $prvkey, $alg);
 
                $headerval = 'keyId="' . $keyid . '",algorithm="' . $algorithm
                        . '",headers="' . $x['headers'] . '",signature="' . $x['signature'] . '"';
 
-               if ($crypt_key) {
-                       $x = Crypto::encapsulate($headerval, $crypt_key, $crypt_algo);
-                       $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data'] . '"';
-               }
-
-               if ($auth) {
-                       $sighead = 'Authorization: Signature ' . $headerval;
-               } else {
-                       $sighead = 'Signature: ' . $headerval;
-               }
+               $sighead = 'Authorization: Signature ' . $headerval;
 
                if ($head) {
                        foreach ($head as $k => $v) {
-                               if ($send_headers) {
-                                       // This is for ActivityPub implementation.
-                                       // Since the Activity Pub implementation isn't
-                                       // ready at the moment, we comment it out.
-                                       // header($k . ': ' . $v);
-                               } else {
-                                       $return_headers[] = $k . ': ' . $v;
-                               }
+                               $return_headers[] = $k . ': ' . $v;
                        }
                }
 
-               if ($send_headers) {
-                       // This is for ActivityPub implementation.
-                       // Since the Activity Pub implementation isn't
-                       // ready at the moment, we comment it out.
-                       // header($sighead);
-               } else {
-                       $return_headers[] = $sighead;
-               }
+               $return_headers[] = $sighead;
 
                return $return_headers;
        }
@@ -280,35 +147,27 @@ class HTTPSignature
        /**
         * @brief
         *
-        * @param string $request
         * @param array  $head
         * @param string $prvkey
         * @param string $alg (optional) default 'sha256'
         *
         * @return array
         */
-       private static function sign($request, $head, $prvkey, $alg = 'sha256')
+       private static function sign($head, $prvkey, $alg = 'sha256')
        {
                $ret = [];
                $headers = '';
                $fields  = '';
 
-               if ($request) {
-                       $headers = '(request-target)' . ': ' . trim($request) . "\n";
-                       $fields = '(request-target)';
-               }
-
-               if ($head) {
-                       foreach ($head as $k => $v) {
-                               $headers .= strtolower($k) . ': ' . trim($v) . "\n";
-                               if ($fields) {
-                                       $fields .= ' ';
-                               }
-                               $fields .= strtolower($k);
+               foreach ($head as $k => $v) {
+                       $headers .= strtolower($k) . ': ' . trim($v) . "\n";
+                       if ($fields) {
+                               $fields .= ' ';
                        }
-                       // strip the trailing linefeed
-                       $headers = rtrim($headers, "\n");
+                       $fields .= strtolower($k);
                }
+               // strip the trailing linefeed
+               $headers = rtrim($headers, "\n");
 
                $sig = base64_encode(Crypto::rsaSign($headers, $prvkey, $alg));
 
@@ -405,4 +264,178 @@ class HTTPSignature
 
                return '';
        }
+
+       /*
+        * Functions for ActivityPub
+        */
+
+       /**
+        * @brief Transmit given data to a target for a user
+        *
+        * @param $data
+        * @param $target
+        * @param $uid
+        */
+       public static function transmit($data, $target, $uid)
+       {
+               $owner = User::getOwnerDataById($uid);
+
+               if (!$owner) {
+                       return;
+               }
+
+               $content = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+
+               // Header data that is about to be signed.
+               $host = parse_url($target, PHP_URL_HOST);
+               $path = parse_url($target, PHP_URL_PATH);
+               $digest = 'SHA-256=' . base64_encode(hash('sha256', $content, true));
+               $content_length = strlen($content);
+
+               $headers = ['Content-Length: ' . $content_length, 'Digest: ' . $digest, 'Host: ' . $host];
+
+               $signed_data = "(request-target): post " . $path . "\ncontent-length: " . $content_length . "\ndigest: " . $digest . "\nhost: " . $host;
+
+               $signature = base64_encode(Crypto::rsaSign($signed_data, $owner['uprvkey'], 'sha256'));
+
+               $headers[] = 'Signature: keyId="' . $owner['url'] . '#main-key' . '",algorithm="rsa-sha256",headers="(request-target) content-length digest host",signature="' . $signature . '"';
+
+               $headers[] = 'Content-Type: application/activity+json';
+
+               Network::post($target, $content, $headers);
+               $return_code = BaseObject::getApp()->get_curl_code();
+
+               logger('Transmit to ' . $target . ' returned ' . $return_code);
+       }
+
+       /**
+        * @brief Gets a signer from a given HTTP request
+        *
+        * @param $content
+        * @param $http_headers
+        *
+        * @return signer string
+        */
+       public static function getSigner($content, $http_headers)
+       {
+               $object = json_decode($content, true);
+
+               if (empty($object)) {
+                       return false;
+               }
+
+               $actor = JsonLD::fetchElement($object, 'actor', 'id');
+
+               $headers = [];
+               $headers['(request-target)'] = strtolower($http_headers['REQUEST_METHOD']) . ' ' . $http_headers['REQUEST_URI'];
+
+               // First take every header
+               foreach ($http_headers as $k => $v) {
+                       $field = str_replace('_', '-', strtolower($k));
+                       $headers[$field] = $v;
+               }
+
+               // Now add every http header
+               foreach ($http_headers as $k => $v) {
+                       if (strpos($k, 'HTTP_') === 0) {
+                               $field = str_replace('_', '-', strtolower(substr($k, 5)));
+                               $headers[$field] = $v;
+                       }
+               }
+
+               $sig_block = self::parseSigHeader($http_headers['HTTP_SIGNATURE']);
+
+               if (empty($sig_block) || empty($sig_block['headers']) || empty($sig_block['keyId'])) {
+                       return false;
+               }
+
+               $signed_data = '';
+               foreach ($sig_block['headers'] as $h) {
+                       if (array_key_exists($h, $headers)) {
+                               $signed_data .= $h . ': ' . $headers[$h] . "\n";
+                       }
+               }
+               $signed_data = rtrim($signed_data, "\n");
+
+               if (empty($signed_data)) {
+                       return false;
+               }
+
+               $algorithm = null;
+
+               if ($sig_block['algorithm'] === 'rsa-sha256') {
+                       $algorithm = 'sha256';
+               }
+
+               if ($sig_block['algorithm'] === 'rsa-sha512') {
+                       $algorithm = 'sha512';
+               }
+
+               if (empty($algorithm)) {
+                       return false;
+               }
+
+               $key = self::fetchKey($sig_block['keyId'], $actor);
+
+               if (empty($key)) {
+                       return false;
+               }
+
+               if (!Crypto::rsaVerify($signed_data, $sig_block['signature'], $key['pubkey'], $algorithm)) {
+                       return false;
+               }
+
+               // Check the digest when it is part of the signed data
+               if (in_array('digest', $sig_block['headers'])) {
+                       $digest = explode('=', $headers['digest'], 2);
+                       if ($digest[0] === 'SHA-256') {
+                               $hashalg = 'sha256';
+                       }
+                       if ($digest[0] === 'SHA-512') {
+                               $hashalg = 'sha512';
+                       }
+
+                       /// @todo add all hashes from the rfc
+
+                       if (!empty($hashalg) && base64_encode(hash($hashalg, $content, true)) != $digest[1]) {
+                               return false;
+                       }
+               }
+
+               // Check the content-length when it is part of the signed data
+               if (in_array('content-length', $sig_block['headers'])) {
+                       if (strlen($content) != $headers['content-length']) {
+                               return false;
+                       }
+               }
+
+               return $key['url'];
+       }
+
+       /**
+        * @brief fetches a key for a given id and actor
+        *
+        * @param $id
+        * @param $actor
+        *
+        * @return array with actor url and public key
+        */
+       private static function fetchKey($id, $actor)
+       {
+               $url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id);
+
+               $profile = APContact::getByURL($url);
+               if (!empty($profile)) {
+                       logger('Taking key from id ' . $id, LOGGER_DEBUG);
+                       return ['url' => $url, 'pubkey' => $profile['pubkey']];
+               } elseif ($url != $actor) {
+                       $profile = APContact::getByURL($actor);
+                       if (!empty($profile)) {
+                               logger('Taking key from actor ' . $actor, LOGGER_DEBUG);
+                               return ['url' => $actor, 'pubkey' => $profile['pubkey']];
+                       }
+               }
+
+               return false;
+       }
 }
diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php
new file mode 100644 (file)
index 0000000..ddf8d93
--- /dev/null
@@ -0,0 +1,143 @@
+<?php
+/**
+ * @file src/Util/JsonLD.php
+ */
+namespace Friendica\Util;
+
+use Friendica\Core\Cache;
+use Exception;
+
+/**
+ * @brief This class contain methods to work with JsonLD data
+ */
+class JsonLD
+{
+       /**
+        * @brief Loader for LD-JSON validation
+        *
+        * @param $url
+        *
+        * @return the loaded data
+        */
+       public static function documentLoader($url)
+       {
+               $recursion = 0;
+
+               $x = debug_backtrace();
+               if ($x) {
+                       foreach ($x as $n) {
+                               if ($n['function'] === __FUNCTION__)  {
+                                       $recursion ++;
+                               }
+                       }
+               }
+
+               if ($recursion > 5) {
+                       logger('jsonld bomb detected at: ' . $url);
+                       exit();
+               }
+
+               $result = Cache::get('documentLoader:' . $url);
+               if (!is_null($result)) {
+                       return $result;
+               }
+
+               $data = jsonld_default_document_loader($url);
+               Cache::set('documentLoader:' . $url, $data, CACHE_DAY);
+               return $data;
+       }
+
+       /**
+        * @brief Normalises a given JSON array
+        *
+        * @param array $json
+        *
+        * @return normalized JSON string
+        */
+       public static function normalize($json)
+       {
+               jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
+
+               $jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
+
+               try {
+                       $normalized = jsonld_normalize($jsonobj, array('algorithm' => 'URDNA2015', 'format' => 'application/nquads'));
+               }
+               catch (Exception $e) {
+                       $normalized = false;
+                       logger('normalise error:' . print_r($e, true), LOGGER_DEBUG);
+               }
+
+               return $normalized;
+       }
+
+       /**
+        * @brief Compacts a given JSON array
+        *
+        * @param array $json
+        *
+        * @return comacted JSON array
+        */
+       public static function compact($json)
+       {
+               jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
+
+               $context = (object)['as' => 'https://www.w3.org/ns/activitystreams',
+                       'w3sec' => 'https://w3id.org/security',
+                       'ostatus' => (object)['@id' => 'http://ostatus.org#', '@type' => '@id'],
+                       'vcard' => (object)['@id' => 'http://www.w3.org/2006/vcard/ns#', '@type' => '@id'],
+                       'uuid' => (object)['@id' => 'http://schema.org/identifier', '@type' => '@id']];
+
+               $jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
+
+               $compacted = jsonld_compact($jsonobj, $context);
+
+               return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
+       }
+
+       /**
+        * @brief Fetches an element from a JSON array
+        *
+        * @param $array
+        * @param $element
+        * @param $key
+        * @param $type
+        * @param $type_value
+        *
+        * @return fetched element
+        */
+       public static function fetchElement($array, $element, $key, $type = null, $type_value = null)
+       {
+               if (empty($array)) {
+                       return false;
+               }
+
+               if (empty($array[$element])) {
+                       return false;
+               }
+
+               if (is_string($array[$element])) {
+                       return $array[$element];
+               }
+
+               if (is_null($type_value)) {
+                       if (!empty($array[$element][$key])) {
+                               return $array[$element][$key];
+                       }
+
+                       if (!empty($array[$element][0][$key])) {
+                               return $array[$element][0][$key];
+                       }
+
+                       return false;
+               }
+
+               if (!empty($array[$element][$key]) && !empty($array[$element][$type]) && ($array[$element][$type] == $type_value)) {
+                       return $array[$element][$key];
+               }
+
+               /// @todo Add array search
+
+               return false;
+       }
+}
diff --git a/src/Util/LDSignature.php b/src/Util/LDSignature.php
new file mode 100644 (file)
index 0000000..7776ec9
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+namespace Friendica\Util;
+
+use Friendica\Util\JsonLD;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Model\APContact;
+
+/**
+ * @brief Implements JSON-LD signatures
+ *
+ * Ported from Osada: https://framagit.org/macgirvin/osada
+ */
+class LDSignature
+{
+       public static function isSigned($data)
+       {
+               return !empty($data['signature']);
+       }
+
+       public static function getSigner($data)
+       {
+               if (!self::isSigned($data)) {
+                       return false;
+               }
+
+               $actor = JsonLD::fetchElement($data, 'actor', 'id');
+               if (empty($actor)) {
+                       return false;
+               }
+
+               $profile = APContact::getByURL($actor);
+               if (empty($profile['pubkey'])) {
+                       return false;
+               }
+               $pubkey = $profile['pubkey'];
+
+               $ohash = self::hash(self::signableOptions($data['signature']));
+               $dhash = self::hash(self::signableData($data));
+
+               $x = Crypto::rsaVerify($ohash . $dhash, base64_decode($data['signature']['signatureValue']), $pubkey);
+               logger('LD-verify: ' . intval($x));
+
+               if (empty($x)) {
+                       return false;
+               } else {
+                       return $actor;
+               }
+       }
+
+       public static function sign($data, $owner)
+       {
+               $options = [
+                       'type' => 'RsaSignature2017',
+                       'nonce' => random_string(64),
+                       'creator' => $owner['url'] . '#main-key',
+                       'created' => DateTimeFormat::utcNow(DateTimeFormat::ATOM)
+               ];
+
+               $ohash = self::hash(self::signableOptions($options));
+               $dhash = self::hash(self::signableData($data));
+               $options['signatureValue'] = base64_encode(Crypto::rsaSign($ohash . $dhash, $owner['uprvkey']));
+
+               return array_merge($data, ['signature' => $options]);
+       }
+
+       private static function signableData($data)
+       {
+               unset($data['signature']);
+               return $data;
+       }
+
+       private static function signableOptions($options)
+       {
+               $newopts = ['@context' => 'https://w3id.org/identity/v1'];
+
+               unset($options['type']);
+               unset($options['id']);
+               unset($options['signatureValue']);
+
+               return array_merge($newopts, $options);
+       }
+
+       private static function hash($obj)
+       {
+               return hash('sha256', JsonLD::normalize($obj));
+       }
+}
diff --git a/src/Worker/APDelivery.php b/src/Worker/APDelivery.php
new file mode 100644 (file)
index 0000000..22b8c8f
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @file src/Worker/APDelivery.php
+ */
+namespace Friendica\Worker;
+
+use Friendica\BaseObject;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Model\Item;
+use Friendica\Util\HTTPSignature;
+
+class APDelivery extends BaseObject
+{
+       public static function execute($cmd, $item_id, $inbox, $uid)
+       {
+               logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
+
+               if ($cmd == Delivery::MAIL) {
+               } elseif ($cmd == Delivery::SUGGESTION) {
+               } elseif ($cmd == Delivery::RELOCATION) {
+               } elseif ($cmd == Delivery::REMOVAL) {
+                       ActivityPub::transmitProfileDeletion($uid, $inbox);
+               } elseif ($cmd == Delivery::PROFILEUPDATE) {
+                       ActivityPub::transmitProfileUpdate($uid, $inbox);
+               } else {
+                       $data = ActivityPub::createActivityFromItem($item_id);
+                       if (!empty($data)) {
+                               HTTPSignature::transmit($data, $inbox, $uid);
+                       }
+               }
+
+               return;
+       }
+}
index 3a93d92f7b37366047dfc551e4c792081c9fb65e..3585b39989d0cefbef1e0c1b6617db5fc2278350 100644 (file)
@@ -22,13 +22,14 @@ require_once 'include/items.php';
 
 class Delivery extends BaseObject
 {
-       const MAIL =       'mail';
-       const SUGGESTION = 'suggest';
-       const RELOCATION = 'relocate';
-       const DELETION =   'drop';
-       const POST =       'wall-new';
-       const COMMENT =    'comment-new';
-       const REMOVAL =    'removeme';
+       const MAIL          = 'mail';
+       const SUGGESTION    = 'suggest';
+       const RELOCATION    = 'relocate';
+       const DELETION      = 'drop';
+       const POST          = 'wall-new';
+       const COMMENT       = 'comment-new';
+       const REMOVAL       = 'removeme';
+       const PROFILEUPDATE = 'profileupdate';
 
        public static function execute($cmd, $item_id, $contact_id)
        {
index 61eaba388b2d365a58829bcf4abddcb1bda54874..3ab238422abad5f6ef20384f9f5c40451cb4151f 100644 (file)
@@ -16,6 +16,7 @@ use Friendica\Model\Item;
 use Friendica\Model\PushSubscriber;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
+use Friendica\Protocol\ActivityPub;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\Salmon;
@@ -98,6 +99,14 @@ class Notifier
                        foreach ($r as $contact) {
                                Contact::terminateFriendship($user, $contact, true);
                        }
+
+                       $inboxes = ActivityPub::fetchTargetInboxesforUser(0);
+                       foreach ($inboxes as $inbox) {
+                               logger('Account removal for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+                               Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
+                                       'APDelivery', Delivery::REMOVAL, '', $inbox, $uid);
+                       }
+
                        return;
                } elseif ($cmd == Delivery::RELOCATION) {
                        $normal_mode = false;
@@ -413,6 +422,24 @@ class Notifier
                        }
                }
 
+               $inboxes = [];
+
+               if ($target_item['origin']) {
+                       $inboxes = ActivityPub::fetchTargetInboxes($target_item, $uid);
+               }
+
+               if ($parent['origin']) {
+                       $parent_inboxes = ActivityPub::fetchTargetInboxes($parent, $uid);
+                       $inboxes = array_merge($inboxes, $parent_inboxes);
+               }
+
+               foreach ($inboxes as $inbox) {
+                       logger('Deliver ' . $item_id .' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+
+                       Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
+                                       'APDelivery', $cmd, $item_id, $inbox, $uid);
+               }
+
                // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
                // They are especially used for notifications to OStatus users that don't follow us.
                if (!Config::get('system', 'dfrn_only') && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
index e33aa5d9a88ad6a2804d044f5242da1f8cbc4771..7fab86cbfdb0f941aa7e860f35821a3cf6d9eb05 100644 (file)
@@ -1,12 +1,15 @@
 <?php
 /**
  * @file src/Worker/ProfileUpdate.php
- * @brief Send updated profile data to Diaspora
+ * @brief Send updated profile data to Diaspora and ActivityPub
  */
 
 namespace Friendica\Worker;
 
+use Friendica\BaseObject;
 use Friendica\Protocol\Diaspora;
+use Friendica\Protocol\ActivityPub;
+use Friendica\Core\Worker;
 
 class ProfileUpdate {
        public static function execute($uid = 0) {
@@ -14,6 +17,16 @@ class ProfileUpdate {
                        return;
                }
 
+               $a = BaseObject::getApp();
+
+               $inboxes = ActivityPub::fetchTargetInboxesforUser($uid);
+
+               foreach ($inboxes as $inbox) {
+                       logger('Profile update for user ' . $uid . ' to ' . $inbox .' via ActivityPub', LOGGER_DEBUG);
+                       Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
+                               'APDelivery', Delivery::PROFILEUPDATE, '', $inbox, $uid);
+               }
+
                Diaspora::sendProfile($uid);
        }
 }
index f2919e4a750e148e0e8531171d9b786e8a1dc3c5..67362917c379418ed2d98652e332e99b351ffd58 100644 (file)
@@ -29,13 +29,13 @@ class UpdateGContact
                        return;
                }
 
-               if (!in_array($r[0]["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+               if (!in_array($r[0]["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        return;
                }
 
                $data = Probe::uri($r[0]["url"]);
 
-               if (!in_array($data["network"], [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
+               if (!in_array($data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS])) {
                        if ($r[0]["server_url"] != "") {
                                PortableContact::checkServer($r[0]["server_url"], $r[0]["network"]);
                        }
index 0495cbb86c5f0b89a7795f337b4e53f049feadfc..c27fb25627bf58611e4c12f336219ac59dd773ed 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: \n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-08-25 15:34+0000\n"
+"POT-Creation-Date: 2018-09-27 21:18+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,47 +18,47 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 
 
-#: index.php:261 mod/apps.php:14
+#: index.php:265 mod/apps.php:14
 msgid "You must be logged in to use addons. "
 msgstr ""
 
-#: index.php:308 mod/fetch.php:20 mod/fetch.php:47 mod/fetch.php:54
+#: index.php:312 mod/fetch.php:20 mod/fetch.php:47 mod/fetch.php:54
 #: mod/help.php:62
 msgid "Not Found"
 msgstr ""
 
-#: index.php:313 mod/viewcontacts.php:35 mod/dfrn_poll.php:486 mod/help.php:65
+#: index.php:317 mod/viewcontacts.php:35 mod/dfrn_poll.php:486 mod/help.php:65
 #: mod/cal.php:44
 msgid "Page not found."
 msgstr ""
 
-#: index.php:431 mod/group.php:83 mod/profperm.php:29
+#: index.php:435 mod/group.php:83 mod/profperm.php:29
 msgid "Permission denied"
 msgstr ""
 
-#: index.php:432 include/items.php:412 mod/crepair.php:100
+#: index.php:436 include/items.php:413 mod/crepair.php:100
 #: mod/wallmessage.php:16 mod/wallmessage.php:40 mod/wallmessage.php:79
-#: mod/wallmessage.php:103 mod/dfrn_confirm.php:66 mod/dirfind.php:27
+#: mod/wallmessage.php:103 mod/dfrn_confirm.php:67 mod/dirfind.php:27
 #: mod/manage.php:131 mod/settings.php:43 mod/settings.php:149
 #: mod/settings.php:665 mod/common.php:28 mod/network.php:34 mod/group.php:26
 #: mod/delegate.php:27 mod/delegate.php:45 mod/delegate.php:56
-#: mod/repair_ostatus.php:16 mod/viewcontacts.php:60 mod/unfollow.php:17
-#: mod/unfollow.php:59 mod/unfollow.php:93 mod/register.php:53
+#: mod/repair_ostatus.php:16 mod/viewcontacts.php:60 mod/unfollow.php:20
+#: mod/unfollow.php:73 mod/unfollow.php:105 mod/register.php:53
 #: mod/notifications.php:67 mod/message.php:60 mod/message.php:105
 #: mod/ostatus_subscribe.php:17 mod/nogroup.php:23 mod/suggest.php:61
 #: mod/wall_upload.php:104 mod/wall_upload.php:107 mod/api.php:35
 #: mod/api.php:40 mod/profile_photo.php:29 mod/profile_photo.php:176
 #: mod/profile_photo.php:198 mod/wall_attach.php:80 mod/wall_attach.php:83
-#: mod/item.php:166 mod/uimport.php:28 mod/cal.php:306 mod/regmod.php:108
+#: mod/item.php:166 mod/uimport.php:15 mod/cal.php:306 mod/regmod.php:108
 #: mod/editpost.php:19 mod/fsuggest.php:80 mod/allfriends.php:23
-#: mod/contacts.php:381 mod/events.php:193 mod/follow.php:54 mod/follow.php:118
-#: mod/attach.php:39 mod/poke.php:145 mod/invite.php:21 mod/invite.php:112
+#: mod/contacts.php:387 mod/events.php:195 mod/follow.php:54 mod/follow.php:118
+#: mod/attach.php:39 mod/poke.php:144 mod/invite.php:21 mod/invite.php:112
 #: mod/notes.php:32 mod/profiles.php:179 mod/profiles.php:511
-#: mod/photos.php:183 mod/photos.php:1065
+#: mod/photos.php:183 mod/photos.php:1067
 msgid "Permission denied."
 msgstr ""
 
-#: index.php:460
+#: index.php:464
 msgid "toggle mobile"
 msgstr ""
 
@@ -92,13 +92,13 @@ msgstr ""
 
 #: view/theme/duepuntozero/config.php:71 view/theme/quattro/config.php:73
 #: view/theme/vier/config.php:119 view/theme/frio/config.php:118
-#: mod/crepair.php:150 mod/install.php:206 mod/install.php:244
+#: mod/crepair.php:150 mod/install.php:204 mod/install.php:242
 #: mod/manage.php:184 mod/message.php:264 mod/message.php:430
-#: mod/fsuggest.php:114 mod/contacts.php:630 mod/events.php:533
-#: mod/localtime.php:56 mod/poke.php:195 mod/invite.php:155
-#: mod/profiles.php:577 mod/photos.php:1094 mod/photos.php:1180
-#: mod/photos.php:1452 mod/photos.php:1497 mod/photos.php:1536
-#: mod/photos.php:1596 src/Object/Post.php:795
+#: mod/fsuggest.php:114 mod/contacts.php:631 mod/events.php:560
+#: mod/localtime.php:56 mod/poke.php:194 mod/invite.php:155
+#: mod/profiles.php:577 mod/photos.php:1096 mod/photos.php:1182
+#: mod/photos.php:1454 mod/photos.php:1499 mod/photos.php:1538
+#: mod/photos.php:1598 src/Object/Post.php:795
 msgid "Submit"
 msgstr ""
 
@@ -186,8 +186,8 @@ msgstr ""
 
 #: view/theme/vier/theme.php:199 include/conversation.php:881
 #: mod/dirfind.php:231 mod/match.php:90 mod/suggest.php:86
-#: mod/allfriends.php:76 mod/contacts.php:604 mod/contacts.php:610
-#: mod/follow.php:143 src/Model/Contact.php:933 src/Content/Widget.php:61
+#: mod/allfriends.php:76 mod/contacts.php:611 mod/follow.php:143
+#: src/Model/Contact.php:944 src/Content/Widget.php:61
 msgid "Connect/Follow"
 msgstr ""
 
@@ -195,7 +195,7 @@ msgstr ""
 msgid "Examples: Robert Morgenstein, Fishing"
 msgstr ""
 
-#: view/theme/vier/theme.php:201 mod/directory.php:214 mod/contacts.php:842
+#: view/theme/vier/theme.php:201 mod/directory.php:214 mod/contacts.php:845
 #: src/Content/Widget.php:63
 msgid "Find"
 msgstr ""
@@ -226,16 +226,16 @@ msgid "Local Directory"
 msgstr ""
 
 #: view/theme/vier/theme.php:251 include/text.php:909 src/Content/Nav.php:151
-#: src/Content/ForumManager.php:125
+#: src/Content/ForumManager.php:130
 msgid "Forums"
 msgstr ""
 
-#: view/theme/vier/theme.php:253 src/Content/ForumManager.php:127
+#: view/theme/vier/theme.php:253 src/Content/ForumManager.php:132
 msgid "External link to forum"
 msgstr ""
 
-#: view/theme/vier/theme.php:256 include/items.php:489 src/Object/Post.php:429
-#: src/App.php:786 src/Content/Widget.php:310 src/Content/ForumManager.php:130
+#: view/theme/vier/theme.php:256 include/items.php:490 src/Object/Post.php:429
+#: src/App.php:799 src/Content/Widget.php:307 src/Content/ForumManager.php:135
 msgid "show more"
 msgstr ""
 
@@ -320,8 +320,8 @@ msgstr ""
 msgid "End this session"
 msgstr ""
 
-#: view/theme/frio/theme.php:269 mod/contacts.php:689 mod/contacts.php:877
-#: src/Model/Profile.php:875 src/Content/Nav.php:100
+#: view/theme/frio/theme.php:269 mod/contacts.php:690 mod/contacts.php:880
+#: src/Model/Profile.php:888 src/Content/Nav.php:100
 msgid "Status"
 msgstr ""
 
@@ -331,8 +331,8 @@ msgid "Your posts and conversations"
 msgstr ""
 
 #: view/theme/frio/theme.php:270 mod/newmember.php:24 mod/profperm.php:116
-#: mod/contacts.php:691 mod/contacts.php:893 src/Model/Profile.php:717
-#: src/Model/Profile.php:850 src/Model/Profile.php:883 src/Content/Nav.php:101
+#: mod/contacts.php:692 mod/contacts.php:896 src/Model/Profile.php:730
+#: src/Model/Profile.php:863 src/Model/Profile.php:896 src/Content/Nav.php:101
 msgid "Profile"
 msgstr ""
 
@@ -340,7 +340,7 @@ msgstr ""
 msgid "Your profile page"
 msgstr ""
 
-#: view/theme/frio/theme.php:271 mod/fbrowser.php:35 src/Model/Profile.php:891
+#: view/theme/frio/theme.php:271 mod/fbrowser.php:35 src/Model/Profile.php:904
 #: src/Content/Nav.php:102
 msgid "Photos"
 msgstr ""
@@ -349,8 +349,8 @@ msgstr ""
 msgid "Your photos"
 msgstr ""
 
-#: view/theme/frio/theme.php:272 src/Model/Profile.php:899
-#: src/Model/Profile.php:902 src/Content/Nav.php:103
+#: view/theme/frio/theme.php:272 src/Model/Profile.php:912
+#: src/Model/Profile.php:915 src/Content/Nav.php:103
 msgid "Videos"
 msgstr ""
 
@@ -359,7 +359,7 @@ msgid "Your videos"
 msgstr ""
 
 #: view/theme/frio/theme.php:273 view/theme/frio/theme.php:277 mod/cal.php:276
-#: mod/events.php:390 src/Model/Profile.php:911 src/Model/Profile.php:922
+#: mod/events.php:391 src/Model/Profile.php:924 src/Model/Profile.php:935
 #: src/Content/Nav.php:104 src/Content/Nav.php:170
 msgid "Events"
 msgstr ""
@@ -377,8 +377,8 @@ msgstr ""
 msgid "Conversations from your friends"
 msgstr ""
 
-#: view/theme/frio/theme.php:277 src/Model/Profile.php:914
-#: src/Model/Profile.php:925 src/Content/Nav.php:170
+#: view/theme/frio/theme.php:277 src/Model/Profile.php:927
+#: src/Model/Profile.php:938 src/Content/Nav.php:170
 msgid "Events and Calendar"
 msgstr ""
 
@@ -400,8 +400,8 @@ msgid "Account settings"
 msgstr ""
 
 #: view/theme/frio/theme.php:280 include/text.php:906 mod/viewcontacts.php:125
-#: mod/contacts.php:836 mod/contacts.php:905 src/Model/Profile.php:954
-#: src/Model/Profile.php:957 src/Content/Nav.php:147 src/Content/Nav.php:213
+#: mod/contacts.php:839 mod/contacts.php:908 src/Model/Profile.php:967
+#: src/Model/Profile.php:970 src/Content/Nav.php:147 src/Content/Nav.php:213
 msgid "Contacts"
 msgstr ""
 
@@ -459,37 +459,37 @@ msgstr ""
 msgid "%s: Updating post-type."
 msgstr ""
 
-#: include/items.php:355 mod/display.php:70 mod/display.php:245
-#: mod/display.php:341 mod/admin.php:283 mod/admin.php:1963 mod/admin.php:2211
+#: include/items.php:356 mod/display.php:71 mod/display.php:254
+#: mod/display.php:350 mod/admin.php:283 mod/admin.php:1963 mod/admin.php:2211
 #: mod/notice.php:22 mod/viewsrc.php:22
 msgid "Item not found."
 msgstr ""
 
-#: include/items.php:393
+#: include/items.php:394
 msgid "Do you really want to delete this item?"
 msgstr ""
 
-#: include/items.php:395 mod/settings.php:1100 mod/settings.php:1106
+#: include/items.php:396 mod/settings.php:1100 mod/settings.php:1106
 #: mod/settings.php:1113 mod/settings.php:1117 mod/settings.php:1121
 #: mod/settings.php:1125 mod/settings.php:1129 mod/settings.php:1133
 #: mod/settings.php:1153 mod/settings.php:1154 mod/settings.php:1155
 #: mod/settings.php:1156 mod/settings.php:1157 mod/register.php:237
 #: mod/message.php:154 mod/suggest.php:40 mod/dfrn_request.php:645
-#: mod/api.php:110 mod/contacts.php:465 mod/follow.php:150 mod/profiles.php:541
+#: mod/api.php:110 mod/contacts.php:471 mod/follow.php:150 mod/profiles.php:541
 #: mod/profiles.php:544 mod/profiles.php:566
 msgid "Yes"
 msgstr ""
 
-#: include/items.php:398 include/conversation.php:1179 mod/videos.php:146
-#: mod/settings.php:676 mod/settings.php:702 mod/unfollow.php:120
+#: include/items.php:399 include/conversation.php:1179 mod/videos.php:146
+#: mod/settings.php:676 mod/settings.php:702 mod/unfollow.php:130
 #: mod/message.php:157 mod/tagrm.php:19 mod/tagrm.php:91 mod/suggest.php:43
-#: mod/dfrn_request.php:655 mod/editpost.php:140 mod/contacts.php:468
+#: mod/dfrn_request.php:655 mod/editpost.php:146 mod/contacts.php:474
 #: mod/follow.php:161 mod/fbrowser.php:104 mod/fbrowser.php:135
 #: mod/photos.php:255 mod/photos.php:327
 msgid "Cancel"
 msgstr ""
 
-#: include/items.php:483 src/Content/Feature.php:96
+#: include/items.php:484 src/Content/Feature.php:96
 msgid "Archives"
 msgstr ""
 
@@ -558,35 +558,35 @@ msgstr ""
 msgid "%1$s marked %2$s's %3$s as favorite"
 msgstr ""
 
-#: include/conversation.php:545 mod/profiles.php:352 mod/photos.php:1507
+#: include/conversation.php:545 mod/profiles.php:352 mod/photos.php:1509
 msgid "Likes"
 msgstr ""
 
-#: include/conversation.php:545 mod/profiles.php:356 mod/photos.php:1507
+#: include/conversation.php:545 mod/profiles.php:356 mod/photos.php:1509
 msgid "Dislikes"
 msgstr ""
 
 #: include/conversation.php:546 include/conversation.php:1492
-#: mod/photos.php:1508
+#: mod/photos.php:1510
 msgid "Attending"
 msgid_plural "Attending"
 msgstr[0] ""
 msgstr[1] ""
 
-#: include/conversation.php:546 mod/photos.php:1508
+#: include/conversation.php:546 mod/photos.php:1510
 msgid "Not attending"
 msgstr ""
 
-#: include/conversation.php:546 mod/photos.php:1508
+#: include/conversation.php:546 mod/photos.php:1510
 msgid "Might attend"
 msgstr ""
 
-#: include/conversation.php:626 mod/photos.php:1564 src/Object/Post.php:195
+#: include/conversation.php:626 mod/photos.php:1566 src/Object/Post.php:195
 msgid "Select"
 msgstr ""
 
 #: include/conversation.php:627 mod/settings.php:736 mod/admin.php:1906
-#: mod/contacts.php:852 mod/contacts.php:1130 mod/photos.php:1565
+#: mod/contacts.php:855 mod/contacts.php:1133 mod/photos.php:1567
 msgid "Delete"
 msgstr ""
 
@@ -614,7 +614,7 @@ msgstr ""
 
 #: include/conversation.php:698 include/conversation.php:1160
 #: mod/wallmessage.php:145 mod/message.php:263 mod/message.php:431
-#: mod/editpost.php:115 mod/photos.php:1480 src/Object/Post.php:401
+#: mod/editpost.php:121 mod/photos.php:1482 src/Object/Post.php:401
 msgid "Please wait"
 msgstr ""
 
@@ -626,36 +626,36 @@ msgstr ""
 msgid "Delete Selected Items"
 msgstr ""
 
-#: include/conversation.php:867 src/Model/Contact.php:937
+#: include/conversation.php:867 src/Model/Contact.php:948
 msgid "View Status"
 msgstr ""
 
 #: include/conversation.php:868 include/conversation.php:884
 #: mod/dirfind.php:230 mod/directory.php:164 mod/match.php:89
-#: mod/suggest.php:85 mod/allfriends.php:75 src/Model/Contact.php:877
-#: src/Model/Contact.php:930 src/Model/Contact.php:938
+#: mod/suggest.php:85 mod/allfriends.php:75 src/Model/Contact.php:888
+#: src/Model/Contact.php:941 src/Model/Contact.php:949
 msgid "View Profile"
 msgstr ""
 
-#: include/conversation.php:869 src/Model/Contact.php:939
+#: include/conversation.php:869 src/Model/Contact.php:950
 msgid "View Photos"
 msgstr ""
 
-#: include/conversation.php:870 src/Model/Contact.php:931
-#: src/Model/Contact.php:940
+#: include/conversation.php:870 src/Model/Contact.php:942
+#: src/Model/Contact.php:951
 msgid "Network Posts"
 msgstr ""
 
-#: include/conversation.php:871 src/Model/Contact.php:932
-#: src/Model/Contact.php:941
+#: include/conversation.php:871 src/Model/Contact.php:943
+#: src/Model/Contact.php:952
 msgid "View Contact"
 msgstr ""
 
-#: include/conversation.php:872 src/Model/Contact.php:943
+#: include/conversation.php:872 src/Model/Contact.php:954
 msgid "Send PM"
 msgstr ""
 
-#: include/conversation.php:876 src/Model/Contact.php:944
+#: include/conversation.php:876 src/Model/Contact.php:955
 msgid "Poke"
 msgstr ""
 
@@ -786,85 +786,85 @@ msgid "Share"
 msgstr ""
 
 #: include/conversation.php:1142 mod/wallmessage.php:143 mod/message.php:261
-#: mod/message.php:428 mod/editpost.php:101
+#: mod/message.php:428 mod/editpost.php:107
 msgid "Upload photo"
 msgstr ""
 
-#: include/conversation.php:1143 mod/editpost.php:102
+#: include/conversation.php:1143 mod/editpost.php:108
 msgid "upload photo"
 msgstr ""
 
-#: include/conversation.php:1144 mod/editpost.php:103
+#: include/conversation.php:1144 mod/editpost.php:109
 msgid "Attach file"
 msgstr ""
 
-#: include/conversation.php:1145 mod/editpost.php:104
+#: include/conversation.php:1145 mod/editpost.php:110
 msgid "attach file"
 msgstr ""
 
 #: include/conversation.php:1146 mod/wallmessage.php:144 mod/message.php:262
-#: mod/message.php:429 mod/editpost.php:105
+#: mod/message.php:429 mod/editpost.php:111
 msgid "Insert web link"
 msgstr ""
 
-#: include/conversation.php:1147 mod/editpost.php:106
+#: include/conversation.php:1147 mod/editpost.php:112
 msgid "web link"
 msgstr ""
 
-#: include/conversation.php:1148 mod/editpost.php:107
+#: include/conversation.php:1148 mod/editpost.php:113
 msgid "Insert video link"
 msgstr ""
 
-#: include/conversation.php:1149 mod/editpost.php:108
+#: include/conversation.php:1149 mod/editpost.php:114
 msgid "video link"
 msgstr ""
 
-#: include/conversation.php:1150 mod/editpost.php:109
+#: include/conversation.php:1150 mod/editpost.php:115
 msgid "Insert audio link"
 msgstr ""
 
-#: include/conversation.php:1151 mod/editpost.php:110
+#: include/conversation.php:1151 mod/editpost.php:116
 msgid "audio link"
 msgstr ""
 
-#: include/conversation.php:1152 mod/editpost.php:111
+#: include/conversation.php:1152 mod/editpost.php:117
 msgid "Set your location"
 msgstr ""
 
-#: include/conversation.php:1153 mod/editpost.php:112
+#: include/conversation.php:1153 mod/editpost.php:118
 msgid "set location"
 msgstr ""
 
-#: include/conversation.php:1154 mod/editpost.php:113
+#: include/conversation.php:1154 mod/editpost.php:119
 msgid "Clear browser location"
 msgstr ""
 
-#: include/conversation.php:1155 mod/editpost.php:114
+#: include/conversation.php:1155 mod/editpost.php:120
 msgid "clear location"
 msgstr ""
 
-#: include/conversation.php:1157 mod/editpost.php:129
+#: include/conversation.php:1157 mod/editpost.php:135
 msgid "Set title"
 msgstr ""
 
-#: include/conversation.php:1159 mod/editpost.php:131
+#: include/conversation.php:1159 mod/editpost.php:137
 msgid "Categories (comma-separated list)"
 msgstr ""
 
-#: include/conversation.php:1161 mod/editpost.php:116
+#: include/conversation.php:1161 mod/editpost.php:122
 msgid "Permission settings"
 msgstr ""
 
-#: include/conversation.php:1162 mod/editpost.php:146
+#: include/conversation.php:1162 mod/editpost.php:152
 msgid "permissions"
 msgstr ""
 
-#: include/conversation.php:1171 mod/editpost.php:126
+#: include/conversation.php:1171 mod/editpost.php:132
 msgid "Public post"
 msgstr ""
 
-#: include/conversation.php:1175 mod/editpost.php:137 mod/events.php:531
-#: mod/photos.php:1498 mod/photos.php:1537 mod/photos.php:1597
+#: include/conversation.php:1175 mod/editpost.php:143 mod/events.php:558
+#: mod/photos.php:1500 mod/photos.php:1539 mod/photos.php:1599
 #: src/Object/Post.php:804
 msgid "Preview"
 msgstr ""
@@ -881,11 +881,11 @@ msgstr ""
 msgid "Private post"
 msgstr ""
 
-#: include/conversation.php:1191 mod/editpost.php:144 src/Model/Profile.php:344
+#: include/conversation.php:1191 mod/editpost.php:150 src/Model/Profile.php:357
 msgid "Message"
 msgstr ""
 
-#: include/conversation.php:1192 mod/editpost.php:145
+#: include/conversation.php:1192 mod/editpost.php:151
 msgid "Browser"
 msgstr ""
 
@@ -911,7 +911,7 @@ msgid_plural "Not Attending"
 msgstr[0] ""
 msgstr[1] ""
 
-#: include/conversation.php:1498 src/Content/ContactSelector.php:122
+#: include/conversation.php:1498 src/Content/ContactSelector.php:127
 msgid "Undecided"
 msgid_plural "Undecided"
 msgstr[0] ""
@@ -1276,7 +1276,7 @@ msgstr[1] ""
 msgid "View Contacts"
 msgstr ""
 
-#: include/text.php:889 mod/filer.php:35 mod/editpost.php:100 mod/notes.php:54
+#: include/text.php:889 mod/filer.php:35 mod/editpost.php:106 mod/notes.php:54
 msgid "Save"
 msgstr ""
 
@@ -1349,132 +1349,132 @@ msgstr ""
 msgid "rebuffed"
 msgstr ""
 
-#: include/text.php:972 mod/settings.php:941 src/Model/Event.php:388
+#: include/text.php:972 mod/settings.php:941 src/Model/Event.php:389
 msgid "Monday"
 msgstr ""
 
-#: include/text.php:972 src/Model/Event.php:389
+#: include/text.php:972 src/Model/Event.php:390
 msgid "Tuesday"
 msgstr ""
 
-#: include/text.php:972 src/Model/Event.php:390
+#: include/text.php:972 src/Model/Event.php:391
 msgid "Wednesday"
 msgstr ""
 
-#: include/text.php:972 src/Model/Event.php:391
+#: include/text.php:972 src/Model/Event.php:392
 msgid "Thursday"
 msgstr ""
 
-#: include/text.php:972 src/Model/Event.php:392
+#: include/text.php:972 src/Model/Event.php:393
 msgid "Friday"
 msgstr ""
 
-#: include/text.php:972 src/Model/Event.php:393
+#: include/text.php:972 src/Model/Event.php:394
 msgid "Saturday"
 msgstr ""
 
-#: include/text.php:972 mod/settings.php:941 src/Model/Event.php:387
+#: include/text.php:972 mod/settings.php:941 src/Model/Event.php:388
 msgid "Sunday"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:408
+#: include/text.php:976 src/Model/Event.php:409
 msgid "January"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:409
+#: include/text.php:976 src/Model/Event.php:410
 msgid "February"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:410
+#: include/text.php:976 src/Model/Event.php:411
 msgid "March"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:411
+#: include/text.php:976 src/Model/Event.php:412
 msgid "April"
 msgstr ""
 
-#: include/text.php:976 include/text.php:993 src/Model/Event.php:399
-#: src/Model/Event.php:412
+#: include/text.php:976 include/text.php:993 src/Model/Event.php:400
+#: src/Model/Event.php:413
 msgid "May"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:413
+#: include/text.php:976 src/Model/Event.php:414
 msgid "June"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:414
+#: include/text.php:976 src/Model/Event.php:415
 msgid "July"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:415
+#: include/text.php:976 src/Model/Event.php:416
 msgid "August"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:416
+#: include/text.php:976 src/Model/Event.php:417
 msgid "September"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:417
+#: include/text.php:976 src/Model/Event.php:418
 msgid "October"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:418
+#: include/text.php:976 src/Model/Event.php:419
 msgid "November"
 msgstr ""
 
-#: include/text.php:976 src/Model/Event.php:419
+#: include/text.php:976 src/Model/Event.php:420
 msgid "December"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:380
+#: include/text.php:990 src/Model/Event.php:381
 msgid "Mon"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:381
+#: include/text.php:990 src/Model/Event.php:382
 msgid "Tue"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:382
+#: include/text.php:990 src/Model/Event.php:383
 msgid "Wed"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:383
+#: include/text.php:990 src/Model/Event.php:384
 msgid "Thu"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:384
+#: include/text.php:990 src/Model/Event.php:385
 msgid "Fri"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:385
+#: include/text.php:990 src/Model/Event.php:386
 msgid "Sat"
 msgstr ""
 
-#: include/text.php:990 src/Model/Event.php:379
+#: include/text.php:990 src/Model/Event.php:380
 msgid "Sun"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:395
+#: include/text.php:993 src/Model/Event.php:396
 msgid "Jan"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:396
+#: include/text.php:993 src/Model/Event.php:397
 msgid "Feb"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:397
+#: include/text.php:993 src/Model/Event.php:398
 msgid "Mar"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:398
+#: include/text.php:993 src/Model/Event.php:399
 msgid "Apr"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:401
+#: include/text.php:993 src/Model/Event.php:402
 msgid "Jul"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:402
+#: include/text.php:993 src/Model/Event.php:403
 msgid "Aug"
 msgstr ""
 
@@ -1482,15 +1482,15 @@ msgstr ""
 msgid "Sep"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:404
+#: include/text.php:993 src/Model/Event.php:405
 msgid "Oct"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:405
+#: include/text.php:993 src/Model/Event.php:406
 msgid "Nov"
 msgstr ""
 
-#: include/text.php:993 src/Model/Event.php:406
+#: include/text.php:993 src/Model/Event.php:407
 msgid "Dec"
 msgstr ""
 
@@ -1499,7 +1499,7 @@ msgstr ""
 msgid "Content warning: %s"
 msgstr ""
 
-#: include/text.php:1204 mod/videos.php:375
+#: include/text.php:1204 mod/videos.php:376
 msgid "View Video"
 msgstr ""
 
@@ -1519,7 +1519,7 @@ msgstr ""
 msgid "view on separate page"
 msgstr ""
 
-#: include/text.php:1421 include/text.php:1428 src/Model/Event.php:609
+#: include/text.php:1421 include/text.php:1428 src/Model/Event.php:616
 msgid "link to source"
 msgstr ""
 
@@ -1541,30 +1541,30 @@ msgstr ""
 msgid "Item filed"
 msgstr ""
 
-#: include/api.php:1138
+#: include/api.php:1140
 #, php-format
 msgid "Daily posting limit of %d post reached. The post was rejected."
 msgid_plural "Daily posting limit of %d posts reached. The post was rejected."
 msgstr[0] ""
 msgstr[1] ""
 
-#: include/api.php:1152
+#: include/api.php:1154
 #, php-format
 msgid "Weekly posting limit of %d post reached. The post was rejected."
 msgid_plural "Weekly posting limit of %d posts reached. The post was rejected."
 msgstr[0] ""
 msgstr[1] ""
 
-#: include/api.php:1166
+#: include/api.php:1168
 #, php-format
 msgid "Monthly posting limit of %d post reached. The post was rejected."
 msgstr ""
 
-#: include/api.php:4233 mod/profile_photo.php:84 mod/profile_photo.php:93
+#: include/api.php:4240 mod/profile_photo.php:84 mod/profile_photo.php:93
 #: mod/profile_photo.php:102 mod/profile_photo.php:211
 #: mod/profile_photo.php:300 mod/profile_photo.php:310 mod/photos.php:90
-#: mod/photos.php:198 mod/photos.php:735 mod/photos.php:1169
-#: mod/photos.php:1186 mod/photos.php:1678 src/Model/User.php:595
+#: mod/photos.php:198 mod/photos.php:735 mod/photos.php:1171
+#: mod/photos.php:1188 mod/photos.php:1680 src/Model/User.php:595
 #: src/Model/User.php:603 src/Model/User.php:611
 msgid "Profile Photos"
 msgstr ""
@@ -1578,7 +1578,7 @@ msgid "Contact update failed."
 msgstr ""
 
 #: mod/crepair.php:112 mod/redir.php:29 mod/redir.php:127
-#: mod/dfrn_confirm.php:127 mod/fsuggest.php:30 mod/fsuggest.php:96
+#: mod/dfrn_confirm.php:128 mod/fsuggest.php:30 mod/fsuggest.php:96
 msgid "Contact not found."
 msgstr ""
 
@@ -1719,143 +1719,143 @@ msgstr ""
 msgid "Your message:"
 msgstr ""
 
-#: mod/lockview.php:42 mod/lockview.php:50
+#: mod/lockview.php:46 mod/lockview.php:57
 msgid "Remote privacy information not available."
 msgstr ""
 
-#: mod/lockview.php:59
+#: mod/lockview.php:66
 msgid "Visible to:"
 msgstr ""
 
-#: mod/install.php:100
+#: mod/install.php:98
 msgid "Friendica Communications Server - Setup"
 msgstr ""
 
-#: mod/install.php:106
+#: mod/install.php:104
 msgid "Could not connect to database."
 msgstr ""
 
-#: mod/install.php:110
+#: mod/install.php:108
 msgid "Could not create table."
 msgstr ""
 
-#: mod/install.php:116
+#: mod/install.php:114
 msgid "Your Friendica site database has been installed."
 msgstr ""
 
-#: mod/install.php:121
+#: mod/install.php:119
 msgid ""
 "You may need to import the file \"database.sql\" manually using phpmyadmin "
 "or mysql."
 msgstr ""
 
-#: mod/install.php:122 mod/install.php:166 mod/install.php:274
+#: mod/install.php:120 mod/install.php:164 mod/install.php:272
 msgid "Please see the file \"INSTALL.txt\"."
 msgstr ""
 
-#: mod/install.php:134
+#: mod/install.php:132
 msgid "Database already in use."
 msgstr ""
 
-#: mod/install.php:163
+#: mod/install.php:161
 msgid "System check"
 msgstr ""
 
-#: mod/install.php:167 mod/cal.php:279 mod/events.php:394
+#: mod/install.php:165 mod/cal.php:279 mod/events.php:395
 msgid "Next"
 msgstr ""
 
-#: mod/install.php:168
+#: mod/install.php:166
 msgid "Check again"
 msgstr ""
 
-#: mod/install.php:187
+#: mod/install.php:185
 msgid "Database connection"
 msgstr ""
 
-#: mod/install.php:188
+#: mod/install.php:186
 msgid ""
 "In order to install Friendica we need to know how to connect to your "
 "database."
 msgstr ""
 
-#: mod/install.php:189
+#: mod/install.php:187
 msgid ""
 "Please contact your hosting provider or site administrator if you have "
 "questions about these settings."
 msgstr ""
 
-#: mod/install.php:190
+#: mod/install.php:188
 msgid ""
 "The database you specify below should already exist. If it does not, please "
 "create it before continuing."
 msgstr ""
 
-#: mod/install.php:194
+#: mod/install.php:192
 msgid "Database Server Name"
 msgstr ""
 
-#: mod/install.php:195
+#: mod/install.php:193
 msgid "Database Login Name"
 msgstr ""
 
-#: mod/install.php:196
+#: mod/install.php:194
 msgid "Database Login Password"
 msgstr ""
 
-#: mod/install.php:196
+#: mod/install.php:194
 msgid "For security reasons the password must not be empty"
 msgstr ""
 
-#: mod/install.php:197
+#: mod/install.php:195
 msgid "Database Name"
 msgstr ""
 
-#: mod/install.php:198 mod/install.php:235
+#: mod/install.php:196 mod/install.php:233
 msgid "Site administrator email address"
 msgstr ""
 
-#: mod/install.php:198 mod/install.php:235
+#: mod/install.php:196 mod/install.php:233
 msgid ""
 "Your account email address must match this in order to use the web admin "
 "panel."
 msgstr ""
 
-#: mod/install.php:200 mod/install.php:238
+#: mod/install.php:198 mod/install.php:236
 msgid "Please select a default timezone for your website"
 msgstr ""
 
-#: mod/install.php:225
+#: mod/install.php:223
 msgid "Site settings"
 msgstr ""
 
-#: mod/install.php:239
+#: mod/install.php:237
 msgid "System Language:"
 msgstr ""
 
-#: mod/install.php:239
+#: mod/install.php:237
 msgid ""
 "Set the default language for your Friendica installation interface and to "
 "send emails."
 msgstr ""
 
-#: mod/install.php:255
+#: mod/install.php:253
 msgid ""
 "The database configuration file \"config/local.ini.php\" could not be "
 "written. Please use the enclosed text to create a configuration file in your "
 "web server root."
 msgstr ""
 
-#: mod/install.php:272
+#: mod/install.php:270
 msgid "<h1>What next</h1>"
 msgstr ""
 
-#: mod/install.php:273
+#: mod/install.php:271
 msgid ""
 "IMPORTANT: You will need to [manually] setup a scheduled task for the worker."
 msgstr ""
 
-#: mod/install.php:276
+#: mod/install.php:274
 #, php-format
 msgid ""
 "Go to your new Friendica node <a href=\"%s/register\">registration page</a> "
@@ -1863,82 +1863,82 @@ msgid ""
 "administrator email. This will allow you to enter the site admin panel."
 msgstr ""
 
-#: mod/dfrn_confirm.php:72 mod/profiles.php:38 mod/profiles.php:148
+#: mod/dfrn_confirm.php:73 mod/profiles.php:38 mod/profiles.php:148
 #: mod/profiles.php:193 mod/profiles.php:523
 msgid "Profile not found."
 msgstr ""
 
-#: mod/dfrn_confirm.php:128
+#: mod/dfrn_confirm.php:129
 msgid ""
 "This may occasionally happen if contact was requested by both persons and it "
 "has already been approved."
 msgstr ""
 
-#: mod/dfrn_confirm.php:238
+#: mod/dfrn_confirm.php:239
 msgid "Response from remote site was not understood."
 msgstr ""
 
-#: mod/dfrn_confirm.php:245 mod/dfrn_confirm.php:251
+#: mod/dfrn_confirm.php:246 mod/dfrn_confirm.php:252
 msgid "Unexpected response from remote site: "
 msgstr ""
 
-#: mod/dfrn_confirm.php:260
+#: mod/dfrn_confirm.php:261
 msgid "Confirmation completed successfully."
 msgstr ""
 
-#: mod/dfrn_confirm.php:272
+#: mod/dfrn_confirm.php:273
 msgid "Temporary failure. Please wait and try again."
 msgstr ""
 
-#: mod/dfrn_confirm.php:275
+#: mod/dfrn_confirm.php:276
 msgid "Introduction failed or was revoked."
 msgstr ""
 
-#: mod/dfrn_confirm.php:280
+#: mod/dfrn_confirm.php:281
 msgid "Remote site reported: "
 msgstr ""
 
-#: mod/dfrn_confirm.php:392
+#: mod/dfrn_confirm.php:382
 msgid "Unable to set contact photo."
 msgstr ""
 
-#: mod/dfrn_confirm.php:450
+#: mod/dfrn_confirm.php:444
 #, php-format
 msgid "No user record found for '%s' "
 msgstr ""
 
-#: mod/dfrn_confirm.php:460
+#: mod/dfrn_confirm.php:454
 msgid "Our site encryption key is apparently messed up."
 msgstr ""
 
-#: mod/dfrn_confirm.php:471
+#: mod/dfrn_confirm.php:465
 msgid "Empty site URL was provided or URL could not be decrypted by us."
 msgstr ""
 
-#: mod/dfrn_confirm.php:487
+#: mod/dfrn_confirm.php:481
 msgid "Contact record was not found for you on our site."
 msgstr ""
 
-#: mod/dfrn_confirm.php:501
+#: mod/dfrn_confirm.php:495
 #, php-format
 msgid "Site public key not available in contact record for URL %s."
 msgstr ""
 
-#: mod/dfrn_confirm.php:517
+#: mod/dfrn_confirm.php:511
 msgid ""
 "The ID provided by your system is a duplicate on our system. It should work "
 "if you try again."
 msgstr ""
 
-#: mod/dfrn_confirm.php:528
+#: mod/dfrn_confirm.php:522
 msgid "Unable to set your contact credentials on our system."
 msgstr ""
 
-#: mod/dfrn_confirm.php:584
+#: mod/dfrn_confirm.php:578
 msgid "Unable to update your contact profile details on our system"
 msgstr ""
 
-#: mod/dfrn_confirm.php:614 mod/dfrn_request.php:561 src/Model/Contact.php:1891
+#: mod/dfrn_confirm.php:608 mod/dfrn_request.php:561 src/Model/Contact.php:1909
 msgid "[Name Withheld]"
 msgstr ""
 
@@ -1953,7 +1953,7 @@ msgid "Forum Search - %s"
 msgstr ""
 
 #: mod/dirfind.php:221 mod/match.php:105 mod/suggest.php:104
-#: mod/allfriends.php:92 src/Model/Profile.php:292 src/Content/Widget.php:37
+#: mod/allfriends.php:92 src/Model/Profile.php:305 src/Content/Widget.php:37
 msgid "Connect"
 msgstr ""
 
@@ -1985,8 +1985,8 @@ msgstr ""
 
 #: mod/videos.php:198 mod/webfinger.php:16 mod/directory.php:42
 #: mod/search.php:105 mod/search.php:111 mod/viewcontacts.php:48
-#: mod/display.php:194 mod/dfrn_request.php:599 mod/probe.php:13
-#: mod/community.php:28 mod/photos.php:945
+#: mod/display.php:203 mod/dfrn_request.php:599 mod/probe.php:13
+#: mod/community.php:28 mod/photos.php:947
 msgid "Public access denied."
 msgstr ""
 
@@ -1994,19 +1994,19 @@ msgstr ""
 msgid "No videos selected"
 msgstr ""
 
-#: mod/videos.php:307 mod/photos.php:1050
+#: mod/videos.php:307 mod/photos.php:1052
 msgid "Access to this item is restricted."
 msgstr ""
 
-#: mod/videos.php:382 mod/photos.php:1699
+#: mod/videos.php:383 mod/photos.php:1701
 msgid "View Album"
 msgstr ""
 
-#: mod/videos.php:390
+#: mod/videos.php:391
 msgid "Recent Videos"
 msgstr ""
 
-#: mod/videos.php:392
+#: mod/videos.php:393
 msgid "Upload New Videos"
 msgstr ""
 
@@ -2014,27 +2014,27 @@ msgstr ""
 msgid "Only logged in users are permitted to perform a probing."
 msgstr ""
 
-#: mod/directory.php:151 mod/notifications.php:253 mod/contacts.php:680
-#: mod/events.php:521 src/Model/Event.php:66 src/Model/Event.php:93
-#: src/Model/Event.php:430 src/Model/Event.php:915 src/Model/Profile.php:417
+#: mod/directory.php:151 mod/notifications.php:248 mod/contacts.php:681
+#: mod/events.php:548 src/Model/Event.php:67 src/Model/Event.php:94
+#: src/Model/Event.php:431 src/Model/Event.php:922 src/Model/Profile.php:430
 msgid "Location:"
 msgstr ""
 
-#: mod/directory.php:156 mod/notifications.php:259 src/Model/Profile.php:420
-#: src/Model/Profile.php:732
+#: mod/directory.php:156 mod/notifications.php:254 src/Model/Profile.php:433
+#: src/Model/Profile.php:745
 msgid "Gender:"
 msgstr ""
 
-#: mod/directory.php:157 src/Model/Profile.php:421 src/Model/Profile.php:756
+#: mod/directory.php:157 src/Model/Profile.php:434 src/Model/Profile.php:769
 msgid "Status:"
 msgstr ""
 
-#: mod/directory.php:158 src/Model/Profile.php:422 src/Model/Profile.php:773
+#: mod/directory.php:158 src/Model/Profile.php:435 src/Model/Profile.php:786
 msgid "Homepage:"
 msgstr ""
 
-#: mod/directory.php:159 mod/notifications.php:255 mod/contacts.php:684
-#: src/Model/Profile.php:423 src/Model/Profile.php:793
+#: mod/directory.php:159 mod/notifications.php:250 mod/contacts.php:685
+#: src/Model/Profile.php:436 src/Model/Profile.php:806
 msgid "About:"
 msgstr ""
 
@@ -2074,7 +2074,7 @@ msgstr ""
 msgid "Account"
 msgstr ""
 
-#: mod/settings.php:64 src/Model/Profile.php:372 src/Content/Nav.php:210
+#: mod/settings.php:64 src/Model/Profile.php:385 src/Content/Nav.php:210
 msgid "Profiles"
 msgstr ""
 
@@ -2114,7 +2114,7 @@ msgstr ""
 msgid "Missing some important data!"
 msgstr ""
 
-#: mod/settings.php:176 mod/settings.php:701 mod/contacts.php:848
+#: mod/settings.php:176 mod/settings.php:701 mod/contacts.php:851
 msgid "Update"
 msgstr ""
 
@@ -2803,7 +2803,7 @@ msgstr ""
 msgid "Basic Settings"
 msgstr ""
 
-#: mod/settings.php:1204 src/Model/Profile.php:725
+#: mod/settings.php:1204 src/Model/Profile.php:738
 msgid "Full Name:"
 msgstr ""
 
@@ -2853,11 +2853,11 @@ msgstr ""
 msgid "(click to open/close)"
 msgstr ""
 
-#: mod/settings.php:1224 mod/photos.php:1126 mod/photos.php:1456
+#: mod/settings.php:1224 mod/photos.php:1128 mod/photos.php:1458
 msgid "Show to Groups"
 msgstr ""
 
-#: mod/settings.php:1225 mod/photos.php:1127 mod/photos.php:1457
+#: mod/settings.php:1225 mod/photos.php:1129 mod/photos.php:1459
 msgid "Show to Contacts"
 msgstr ""
 
@@ -3006,7 +3006,7 @@ msgstr ""
 msgid "Items tagged with: %s"
 msgstr ""
 
-#: mod/search.php:248 mod/contacts.php:841
+#: mod/search.php:248 mod/contacts.php:844
 #, php-format
 msgid "Results for: %s"
 msgstr ""
@@ -3015,7 +3015,7 @@ msgstr ""
 msgid "No contacts in common."
 msgstr ""
 
-#: mod/common.php:142 mod/contacts.php:916
+#: mod/common.php:142 mod/contacts.php:919
 msgid "Common Friends"
 msgstr ""
 
@@ -3023,7 +3023,11 @@ msgstr ""
 msgid "Login"
 msgstr ""
 
-#: mod/bookmarklet.php:52
+#: mod/bookmarklet.php:34
+msgid "Bad Request"
+msgstr ""
+
+#: mod/bookmarklet.php:56
 msgid "The post was created"
 msgstr ""
 
@@ -3173,7 +3177,7 @@ msgstr ""
 msgid "Members"
 msgstr ""
 
-#: mod/group.php:246 mod/contacts.php:739
+#: mod/group.php:246 mod/contacts.php:742
 msgid "All Contacts"
 msgstr ""
 
@@ -3297,46 +3301,42 @@ msgstr ""
 msgid "No contacts."
 msgstr ""
 
-#: mod/viewcontacts.php:106 mod/contacts.php:639 mod/contacts.php:1052
+#: mod/viewcontacts.php:106 mod/contacts.php:640 mod/contacts.php:1055
 #, php-format
 msgid "Visit %s's profile [%s]"
 msgstr ""
 
-#: mod/unfollow.php:36
-msgid "Contact wasn't found or can't be unfollowed."
-msgstr ""
-
-#: mod/unfollow.php:49
-msgid "Contact unfollowed"
-msgstr ""
-
-#: mod/unfollow.php:67 mod/dfrn_request.php:654 mod/follow.php:62
-msgid "Submit Request"
+#: mod/unfollow.php:38 mod/unfollow.php:88
+msgid "You aren't following this contact."
 msgstr ""
 
-#: mod/unfollow.php:76
-msgid "You aren't a friend of this contact."
+#: mod/unfollow.php:44 mod/unfollow.php:94
+msgid "Unfollowing is currently not supported by your network."
 msgstr ""
 
-#: mod/unfollow.php:82
-msgid "Unfollowing is currently not supported by your network."
+#: mod/unfollow.php:65
+msgid "Contact unfollowed"
 msgstr ""
 
-#: mod/unfollow.php:103 mod/contacts.php:601
+#: mod/unfollow.php:113 mod/contacts.php:607
 msgid "Disconnect/Unfollow"
 msgstr ""
 
-#: mod/unfollow.php:116 mod/dfrn_request.php:652 mod/follow.php:157
+#: mod/unfollow.php:126 mod/dfrn_request.php:652 mod/follow.php:157
 msgid "Your Identity Address:"
 msgstr ""
 
-#: mod/unfollow.php:125 mod/notifications.php:174 mod/notifications.php:263
-#: mod/admin.php:500 mod/admin.php:510 mod/contacts.php:676 mod/follow.php:166
+#: mod/unfollow.php:129 mod/dfrn_request.php:654 mod/follow.php:62
+msgid "Submit Request"
+msgstr ""
+
+#: mod/unfollow.php:135 mod/notifications.php:174 mod/notifications.php:258
+#: mod/admin.php:500 mod/admin.php:510 mod/contacts.php:677 mod/follow.php:166
 msgid "Profile URL"
 msgstr ""
 
-#: mod/unfollow.php:135 mod/contacts.php:888 mod/follow.php:189
-#: src/Model/Profile.php:878
+#: mod/unfollow.php:145 mod/contacts.php:891 mod/follow.php:189
+#: src/Model/Profile.php:891
 msgid "Status Messages and Posts"
 msgstr ""
 
@@ -3370,7 +3370,7 @@ msgstr ""
 msgid "Your registration is pending approval by the site owner."
 msgstr ""
 
-#: mod/register.php:191 mod/uimport.php:55
+#: mod/register.php:191 mod/uimport.php:37
 msgid ""
 "This site has exceeded the number of allowed daily account registrations. "
 "Please try again tomorrow."
@@ -3445,7 +3445,7 @@ msgstr ""
 msgid "Register"
 msgstr ""
 
-#: mod/register.php:287 mod/uimport.php:70
+#: mod/register.php:287 mod/uimport.php:52
 msgid "Import"
 msgstr ""
 
@@ -3466,36 +3466,44 @@ msgstr ""
 msgid "Invalid request identifier."
 msgstr ""
 
-#: mod/notifications.php:44 mod/notifications.php:183 mod/notifications.php:235
+#: mod/notifications.php:44 mod/notifications.php:182 mod/notifications.php:230
 #: mod/message.php:114
 msgid "Discard"
 msgstr ""
 
-#: mod/notifications.php:57 mod/notifications.php:182 mod/notifications.php:271
-#: mod/contacts.php:658 mod/contacts.php:850 mod/contacts.php:1113
+#: mod/notifications.php:57 mod/notifications.php:181 mod/notifications.php:266
+#: mod/contacts.php:659 mod/contacts.php:853 mod/contacts.php:1116
 msgid "Ignore"
 msgstr ""
 
-#: mod/notifications.php:93 src/Content/Nav.php:191
+#: mod/notifications.php:90 src/Content/Nav.php:191
 msgid "Notifications"
 msgstr ""
 
-#: mod/notifications.php:101
+#: mod/notifications.php:102
 msgid "Network Notifications"
 msgstr ""
 
-#: mod/notifications.php:106 mod/notify.php:81
+#: mod/notifications.php:107 mod/notify.php:81
 msgid "System Notifications"
 msgstr ""
 
-#: mod/notifications.php:111
+#: mod/notifications.php:112
 msgid "Personal Notifications"
 msgstr ""
 
-#: mod/notifications.php:116
+#: mod/notifications.php:117
 msgid "Home Notifications"
 msgstr ""
 
+#: mod/notifications.php:137
+msgid "Show unread"
+msgstr ""
+
+#: mod/notifications.php:137
+msgid "Show all"
+msgstr ""
+
 #: mod/notifications.php:148
 msgid "Show Ignored Requests"
 msgstr ""
@@ -3504,7 +3512,7 @@ msgstr ""
 msgid "Hide Ignored Requests"
 msgstr ""
 
-#: mod/notifications.php:161 mod/notifications.php:243
+#: mod/notifications.php:161 mod/notifications.php:238
 msgid "Notification type:"
 msgstr ""
 
@@ -3512,85 +3520,77 @@ msgstr ""
 msgid "Suggested by:"
 msgstr ""
 
-#: mod/notifications.php:176 mod/notifications.php:260 mod/contacts.php:666
+#: mod/notifications.php:176 mod/notifications.php:255 mod/contacts.php:667
 msgid "Hide this contact from others"
 msgstr ""
 
-#: mod/notifications.php:179 mod/notifications.php:269 mod/admin.php:1904
+#: mod/notifications.php:178 mod/notifications.php:264 mod/admin.php:1904
 msgid "Approve"
 msgstr ""
 
-#: mod/notifications.php:202
+#: mod/notifications.php:198
 msgid "Claims to be known to you: "
 msgstr ""
 
-#: mod/notifications.php:203
+#: mod/notifications.php:199
 msgid "yes"
 msgstr ""
 
-#: mod/notifications.php:203
+#: mod/notifications.php:199
 msgid "no"
 msgstr ""
 
-#: mod/notifications.php:204 mod/notifications.php:209
+#: mod/notifications.php:200 mod/notifications.php:204
 msgid "Shall your connection be bidirectional or not?"
 msgstr ""
 
-#: mod/notifications.php:205 mod/notifications.php:210
+#: mod/notifications.php:201 mod/notifications.php:205
 #, php-format
 msgid ""
 "Accepting %s as a friend allows %s to subscribe to your posts, and you will "
 "also receive updates from them in your news feed."
 msgstr ""
 
-#: mod/notifications.php:206
+#: mod/notifications.php:202
 #, php-format
 msgid ""
 "Accepting %s as a subscriber allows them to subscribe to your posts, but you "
 "will not receive updates from them in your news feed."
 msgstr ""
 
-#: mod/notifications.php:211
+#: mod/notifications.php:206
 #, php-format
 msgid ""
 "Accepting %s as a sharer allows them to subscribe to your posts, but you "
 "will not receive updates from them in your news feed."
 msgstr ""
 
-#: mod/notifications.php:222
+#: mod/notifications.php:217
 msgid "Friend"
 msgstr ""
 
-#: mod/notifications.php:223
+#: mod/notifications.php:218
 msgid "Sharer"
 msgstr ""
 
-#: mod/notifications.php:223
+#: mod/notifications.php:218
 msgid "Subscriber"
 msgstr ""
 
-#: mod/notifications.php:257 mod/contacts.php:686 mod/follow.php:177
-#: src/Model/Profile.php:781
+#: mod/notifications.php:252 mod/contacts.php:687 mod/follow.php:177
+#: src/Model/Profile.php:794
 msgid "Tags:"
 msgstr ""
 
-#: mod/notifications.php:266 mod/contacts.php:76 src/Model/Profile.php:520
+#: mod/notifications.php:261 mod/contacts.php:81 src/Model/Profile.php:533
 msgid "Network:"
 msgstr ""
 
-#: mod/notifications.php:280
+#: mod/notifications.php:274
 msgid "No introductions."
 msgstr ""
 
-#: mod/notifications.php:318
-msgid "Show unread"
-msgstr ""
-
-#: mod/notifications.php:318
-msgid "Show all"
-msgstr ""
-
-#: mod/notifications.php:323
+#: mod/notifications.php:308
 #, php-format
 msgid "No more %s notifications."
 msgstr ""
@@ -3812,7 +3812,7 @@ msgid "On this server the following remote servers are blocked."
 msgstr ""
 
 #: mod/friendica.php:130 mod/admin.php:363 mod/admin.php:381
-#: mod/dfrn_request.php:345 src/Model/Contact.php:1582
+#: mod/dfrn_request.php:345 src/Model/Contact.php:1593
 msgid "Blocked domain"
 msgstr ""
 
@@ -3820,7 +3820,7 @@ msgstr ""
 msgid "Reason for the block"
 msgstr ""
 
-#: mod/display.php:303 mod/cal.php:144 mod/profile.php:175
+#: mod/display.php:312 mod/cal.php:144 mod/profile.php:185
 msgid "Access to this profile has been restricted."
 msgstr ""
 
@@ -3830,13 +3830,13 @@ msgstr ""
 msgid "Invalid request."
 msgstr ""
 
-#: mod/wall_upload.php:195 mod/profile_photo.php:151 mod/photos.php:776
-#: mod/photos.php:779 mod/photos.php:808
+#: mod/wall_upload.php:195 mod/profile_photo.php:151 mod/photos.php:778
+#: mod/photos.php:781 mod/photos.php:810
 #, php-format
 msgid "Image exceeds size limit of %s"
 msgstr ""
 
-#: mod/wall_upload.php:209 mod/profile_photo.php:160 mod/photos.php:831
+#: mod/wall_upload.php:209 mod/profile_photo.php:160 mod/photos.php:833
 msgid "Unable to process image."
 msgstr ""
 
@@ -3845,7 +3845,7 @@ msgstr ""
 msgid "Wall Photos"
 msgstr ""
 
-#: mod/wall_upload.php:248 mod/profile_photo.php:305 mod/photos.php:860
+#: mod/wall_upload.php:248 mod/profile_photo.php:305 mod/photos.php:862
 msgid "Image upload failed."
 msgstr ""
 
@@ -4156,79 +4156,91 @@ msgstr ""
 msgid "Your password has been changed at %s"
 msgstr ""
 
-#: mod/babel.php:22
+#: mod/babel.php:24
 msgid "Source input"
 msgstr ""
 
-#: mod/babel.php:28
+#: mod/babel.php:30
 msgid "BBCode::toPlaintext"
 msgstr ""
 
-#: mod/babel.php:34
+#: mod/babel.php:36
 msgid "BBCode::convert (raw HTML)"
 msgstr ""
 
-#: mod/babel.php:39
+#: mod/babel.php:41
 msgid "BBCode::convert"
 msgstr ""
 
-#: mod/babel.php:45
+#: mod/babel.php:47
 msgid "BBCode::convert => HTML::toBBCode"
 msgstr ""
 
-#: mod/babel.php:51
+#: mod/babel.php:53
 msgid "BBCode::toMarkdown"
 msgstr ""
 
-#: mod/babel.php:57
+#: mod/babel.php:59
 msgid "BBCode::toMarkdown => Markdown::convert"
 msgstr ""
 
-#: mod/babel.php:63
+#: mod/babel.php:65
 msgid "BBCode::toMarkdown => Markdown::toBBCode"
 msgstr ""
 
-#: mod/babel.php:69
+#: mod/babel.php:71
 msgid "BBCode::toMarkdown =>  Markdown::convert => HTML::toBBCode"
 msgstr ""
 
-#: mod/babel.php:76
-msgid "Source input \\x28Diaspora format\\x29"
+#: mod/babel.php:78
+msgid "Source input (Diaspora format)"
 msgstr ""
 
-#: mod/babel.php:82
-msgid "Markdown::toBBCode"
+#: mod/babel.php:84
+msgid "Markdown::convert (raw HTML)"
 msgstr ""
 
 #: mod/babel.php:89
+msgid "Markdown::convert"
+msgstr ""
+
+#: mod/babel.php:95
+msgid "Markdown::toBBCode"
+msgstr ""
+
+#: mod/babel.php:102
 msgid "Raw HTML input"
 msgstr ""
 
-#: mod/babel.php:94
+#: mod/babel.php:107
 msgid "HTML Input"
 msgstr ""
 
-#: mod/babel.php:100
+#: mod/babel.php:113
 msgid "HTML::toBBCode"
 msgstr ""
 
-#: mod/babel.php:106
+#: mod/babel.php:119
+msgid "HTML::toMarkdown"
+msgstr ""
+
+#: mod/babel.php:125
 msgid "HTML::toPlaintext"
 msgstr ""
 
-#: mod/babel.php:114
+#: mod/babel.php:133
 msgid "Source text"
 msgstr ""
 
-#: mod/babel.php:115
+#: mod/babel.php:134
 msgid "BBCode"
 msgstr ""
 
-#: mod/babel.php:116
+#: mod/babel.php:135
 msgid "Markdown"
 msgstr ""
 
-#: mod/babel.php:117
+#: mod/babel.php:136
 msgid "HTML"
 msgstr ""
 
@@ -4488,13 +4500,13 @@ msgstr ""
 msgid "select none"
 msgstr ""
 
-#: mod/admin.php:494 mod/admin.php:1907 mod/contacts.php:657
-#: mod/contacts.php:849 mod/contacts.php:1105
+#: mod/admin.php:494 mod/admin.php:1907 mod/contacts.php:658
+#: mod/contacts.php:852 mod/contacts.php:1108
 msgid "Block"
 msgstr ""
 
-#: mod/admin.php:495 mod/admin.php:1909 mod/contacts.php:657
-#: mod/contacts.php:849 mod/contacts.php:1105
+#: mod/admin.php:495 mod/admin.php:1909 mod/contacts.php:658
+#: mod/contacts.php:852 mod/contacts.php:1108
 msgid "Unblock"
 msgstr ""
 
@@ -4675,9 +4687,9 @@ msgstr ""
 #: mod/admin.php:876
 #, php-format
 msgid ""
-"<a href=\"%s\">%s</a> is not reachable on your system. This is a servere "
-"configuration issue that prevents the communication.. See <a href=\"%s\">the "
-"installation page</a> for help."
+"<a href=\"%s\">%s</a> is not reachable on your system. This is a severe "
+"configuration issue that prevents server to server communication. See <a "
+"href=\"%s\">the installation page</a> for help."
 msgstr ""
 
 #: mod/admin.php:882
@@ -4757,7 +4769,7 @@ msgid "Public postings from local users and the federated network"
 msgstr ""
 
 #: mod/admin.php:1353 mod/admin.php:1520 mod/admin.php:1530
-#: mod/contacts.php:577
+#: mod/contacts.php:583
 msgid "Disabled"
 msgstr ""
 
@@ -4837,8 +4849,8 @@ msgstr ""
 msgid "Policies"
 msgstr ""
 
-#: mod/admin.php:1431 mod/contacts.php:926 mod/events.php:535
-#: src/Model/Profile.php:852
+#: mod/admin.php:1431 mod/contacts.php:929 mod/events.php:562
+#: src/Model/Profile.php:865
 msgid "Advanced"
 msgstr ""
 
@@ -5241,14 +5253,14 @@ msgid ""
 msgstr ""
 
 #: mod/admin.php:1481
-msgid "Only import OStatus threads from our contacts"
+msgid "Only import OStatus/ActivityPub threads from our contacts"
 msgstr ""
 
 #: mod/admin.php:1481
 msgid ""
-"Normally we import every content from our OStatus contacts. With this option "
-"we only store threads that are started by a contact that is known on our "
-"system."
+"Normally we import every content from our OStatus and ActivityPub contacts. "
+"With this option we only store threads that are started by a contact that is "
+"known on our system."
 msgstr ""
 
 #: mod/admin.php:1482
@@ -6127,11 +6139,11 @@ msgstr ""
 msgid "Invalid profile URL."
 msgstr ""
 
-#: mod/dfrn_request.php:339 src/Model/Contact.php:1577
+#: mod/dfrn_request.php:339 src/Model/Contact.php:1588
 msgid "Disallowed profile URL."
 msgstr ""
 
-#: mod/dfrn_request.php:412 mod/contacts.php:235
+#: mod/dfrn_request.php:412 mod/contacts.php:241
 msgid "Failed to update contact record."
 msgstr ""
 
@@ -6357,32 +6369,36 @@ msgstr ""
 msgid "Help:"
 msgstr ""
 
-#: mod/uimport.php:72
+#: mod/uimport.php:28
+msgid "User imports on closed servers can only be done by an administrator."
+msgstr ""
+
+#: mod/uimport.php:54
 msgid "Move account"
 msgstr ""
 
-#: mod/uimport.php:73
+#: mod/uimport.php:55
 msgid "You can import an account from another Friendica server."
 msgstr ""
 
-#: mod/uimport.php:74
+#: mod/uimport.php:56
 msgid ""
 "You need to export your account from the old server and upload it here. We "
 "will recreate your old account here with all your contacts. We will try also "
 "to inform your friends that you moved here."
 msgstr ""
 
-#: mod/uimport.php:75
+#: mod/uimport.php:57
 msgid ""
 "This feature is experimental. We can't import contacts from the OStatus "
 "network (GNU Social/Statusnet) or from Diaspora"
 msgstr ""
 
-#: mod/uimport.php:76
+#: mod/uimport.php:58
 msgid "Account file"
 msgstr ""
 
-#: mod/uimport.php:76
+#: mod/uimport.php:58
 msgid ""
 "To export your account, go to \"Settings->Export your personal data\" and "
 "select \"Export account\""
@@ -6404,34 +6420,34 @@ msgstr ""
 msgid "All Contacts (with secure profile access)"
 msgstr ""
 
-#: mod/cal.php:277 mod/events.php:391
+#: mod/cal.php:277 mod/events.php:392
 msgid "View"
 msgstr ""
 
-#: mod/cal.php:278 mod/events.php:393
+#: mod/cal.php:278 mod/events.php:394
 msgid "Previous"
 msgstr ""
 
-#: mod/cal.php:282 mod/events.php:399 src/Model/Event.php:421
+#: mod/cal.php:282 mod/events.php:400 src/Model/Event.php:422
 msgid "today"
 msgstr ""
 
-#: mod/cal.php:283 mod/events.php:400 src/Util/Temporal.php:304
-#: src/Model/Event.php:422
+#: mod/cal.php:283 mod/events.php:401 src/Util/Temporal.php:304
+#: src/Model/Event.php:423
 msgid "month"
 msgstr ""
 
-#: mod/cal.php:284 mod/events.php:401 src/Util/Temporal.php:305
-#: src/Model/Event.php:423
+#: mod/cal.php:284 mod/events.php:402 src/Util/Temporal.php:305
+#: src/Model/Event.php:424
 msgid "week"
 msgstr ""
 
-#: mod/cal.php:285 mod/events.php:402 src/Util/Temporal.php:306
-#: src/Model/Event.php:424
+#: mod/cal.php:285 mod/events.php:403 src/Util/Temporal.php:306
+#: src/Model/Event.php:425
 msgid "day"
 msgstr ""
 
-#: mod/cal.php:286 mod/events.php:403
+#: mod/cal.php:286 mod/events.php:404
 msgid "list"
 msgstr ""
 
@@ -6464,19 +6480,19 @@ msgstr ""
 msgid "Please login."
 msgstr ""
 
-#: mod/editpost.php:26 mod/editpost.php:36
+#: mod/editpost.php:27 mod/editpost.php:42
 msgid "Item not found"
 msgstr ""
 
-#: mod/editpost.php:43
+#: mod/editpost.php:49
 msgid "Edit post"
 msgstr ""
 
-#: mod/editpost.php:125 src/Core/ACL.php:304
+#: mod/editpost.php:131 src/Core/ACL.php:304
 msgid "CC: email addresses"
 msgstr ""
 
-#: mod/editpost.php:132 src/Core/ACL.php:305
+#: mod/editpost.php:138 src/Core/ACL.php:305
 msgid "Example: bob@example.com, mary@example.com"
 msgstr ""
 
@@ -6513,21 +6529,21 @@ msgstr ""
 msgid "System down for maintenance"
 msgstr ""
 
-#: mod/profile.php:38 src/Model/Profile.php:115
+#: mod/profile.php:39 src/Model/Profile.php:128
 msgid "Requested profile is not available."
 msgstr ""
 
-#: mod/profile.php:79 mod/profile.php:82 src/Protocol/OStatus.php:1275
+#: mod/profile.php:89 mod/profile.php:92 src/Protocol/OStatus.php:1285
 #, php-format
 msgid "%s's timeline"
 msgstr ""
 
-#: mod/profile.php:80 src/Protocol/OStatus.php:1276
+#: mod/profile.php:90 src/Protocol/OStatus.php:1286
 #, php-format
 msgid "%s's posts"
 msgstr ""
 
-#: mod/profile.php:81 src/Protocol/OStatus.php:1277
+#: mod/profile.php:91 src/Protocol/OStatus.php:1287
 #, php-format
 msgid "%s's comments"
 msgstr ""
@@ -6536,433 +6552,433 @@ msgstr ""
 msgid "No friends to display."
 msgstr ""
 
-#: mod/contacts.php:162
+#: mod/contacts.php:168
 #, php-format
 msgid "%d contact edited."
 msgid_plural "%d contacts edited."
 msgstr[0] ""
 msgstr[1] ""
 
-#: mod/contacts.php:189 mod/contacts.php:395
+#: mod/contacts.php:195 mod/contacts.php:401
 msgid "Could not access contact record."
 msgstr ""
 
-#: mod/contacts.php:199
+#: mod/contacts.php:205
 msgid "Could not locate selected profile."
 msgstr ""
 
-#: mod/contacts.php:233
+#: mod/contacts.php:239
 msgid "Contact updated."
 msgstr ""
 
-#: mod/contacts.php:416
+#: mod/contacts.php:422
 msgid "Contact has been blocked"
 msgstr ""
 
-#: mod/contacts.php:416
+#: mod/contacts.php:422
 msgid "Contact has been unblocked"
 msgstr ""
 
-#: mod/contacts.php:426
+#: mod/contacts.php:432
 msgid "Contact has been ignored"
 msgstr ""
 
-#: mod/contacts.php:426
+#: mod/contacts.php:432
 msgid "Contact has been unignored"
 msgstr ""
 
-#: mod/contacts.php:436
+#: mod/contacts.php:442
 msgid "Contact has been archived"
 msgstr ""
 
-#: mod/contacts.php:436
+#: mod/contacts.php:442
 msgid "Contact has been unarchived"
 msgstr ""
 
-#: mod/contacts.php:460
+#: mod/contacts.php:466
 msgid "Drop contact"
 msgstr ""
 
-#: mod/contacts.php:463 mod/contacts.php:845
+#: mod/contacts.php:469 mod/contacts.php:848
 msgid "Do you really want to delete this contact?"
 msgstr ""
 
-#: mod/contacts.php:481
+#: mod/contacts.php:487
 msgid "Contact has been removed."
 msgstr ""
 
-#: mod/contacts.php:518
+#: mod/contacts.php:524
 #, php-format
 msgid "You are mutual friends with %s"
 msgstr ""
 
-#: mod/contacts.php:523
+#: mod/contacts.php:529
 #, php-format
 msgid "You are sharing with %s"
 msgstr ""
 
-#: mod/contacts.php:528
+#: mod/contacts.php:534
 #, php-format
 msgid "%s is sharing with you"
 msgstr ""
 
-#: mod/contacts.php:552
+#: mod/contacts.php:558
 msgid "Private communications are not available for this contact."
 msgstr ""
 
-#: mod/contacts.php:554
+#: mod/contacts.php:560
 msgid "Never"
 msgstr ""
 
-#: mod/contacts.php:557
+#: mod/contacts.php:563
 msgid "(Update was successful)"
 msgstr ""
 
-#: mod/contacts.php:557
+#: mod/contacts.php:563
 msgid "(Update was not successful)"
 msgstr ""
 
-#: mod/contacts.php:559 mod/contacts.php:1086
+#: mod/contacts.php:565 mod/contacts.php:1089
 msgid "Suggest friends"
 msgstr ""
 
-#: mod/contacts.php:563
+#: mod/contacts.php:569
 #, php-format
 msgid "Network type: %s"
 msgstr ""
 
-#: mod/contacts.php:568
+#: mod/contacts.php:574
 msgid "Communications lost with this contact!"
 msgstr ""
 
-#: mod/contacts.php:574
+#: mod/contacts.php:580
 msgid "Fetch further information for feeds"
 msgstr ""
 
-#: mod/contacts.php:576
+#: mod/contacts.php:582
 msgid ""
 "Fetch information like preview pictures, title and teaser from the feed "
 "item. You can activate this if the feed doesn't contain much text. Keywords "
 "are taken from the meta header in the feed item and are posted as hash tags."
 msgstr ""
 
-#: mod/contacts.php:578
+#: mod/contacts.php:584
 msgid "Fetch information"
 msgstr ""
 
-#: mod/contacts.php:579
+#: mod/contacts.php:585
 msgid "Fetch keywords"
 msgstr ""
 
-#: mod/contacts.php:580
+#: mod/contacts.php:586
 msgid "Fetch information and keywords"
 msgstr ""
 
-#: mod/contacts.php:617
+#: mod/contacts.php:618
 msgid "Profile Visibility"
 msgstr ""
 
-#: mod/contacts.php:618
+#: mod/contacts.php:619
 msgid "Contact Information / Notes"
 msgstr ""
 
-#: mod/contacts.php:619
+#: mod/contacts.php:620
 msgid "Contact Settings"
 msgstr ""
 
-#: mod/contacts.php:628
+#: mod/contacts.php:629
 msgid "Contact"
 msgstr ""
 
-#: mod/contacts.php:632
+#: mod/contacts.php:633
 #, php-format
 msgid ""
 "Please choose the profile you would like to display to %s when viewing your "
 "profile securely."
 msgstr ""
 
-#: mod/contacts.php:634
+#: mod/contacts.php:635
 msgid "Their personal note"
 msgstr ""
 
-#: mod/contacts.php:636
+#: mod/contacts.php:637
 msgid "Edit contact notes"
 msgstr ""
 
-#: mod/contacts.php:640
+#: mod/contacts.php:641
 msgid "Block/Unblock contact"
 msgstr ""
 
-#: mod/contacts.php:641
+#: mod/contacts.php:642
 msgid "Ignore contact"
 msgstr ""
 
-#: mod/contacts.php:642
+#: mod/contacts.php:643
 msgid "Repair URL settings"
 msgstr ""
 
-#: mod/contacts.php:643
+#: mod/contacts.php:644
 msgid "View conversations"
 msgstr ""
 
-#: mod/contacts.php:648
+#: mod/contacts.php:649
 msgid "Last update:"
 msgstr ""
 
-#: mod/contacts.php:650
+#: mod/contacts.php:651
 msgid "Update public posts"
 msgstr ""
 
-#: mod/contacts.php:652 mod/contacts.php:1096
+#: mod/contacts.php:653 mod/contacts.php:1099
 msgid "Update now"
 msgstr ""
 
-#: mod/contacts.php:658 mod/contacts.php:850 mod/contacts.php:1113
+#: mod/contacts.php:659 mod/contacts.php:853 mod/contacts.php:1116
 msgid "Unignore"
 msgstr ""
 
-#: mod/contacts.php:662
+#: mod/contacts.php:663
 msgid "Currently blocked"
 msgstr ""
 
-#: mod/contacts.php:663
+#: mod/contacts.php:664
 msgid "Currently ignored"
 msgstr ""
 
-#: mod/contacts.php:664
+#: mod/contacts.php:665
 msgid "Currently archived"
 msgstr ""
 
-#: mod/contacts.php:665
+#: mod/contacts.php:666
 msgid "Awaiting connection acknowledge"
 msgstr ""
 
-#: mod/contacts.php:666
+#: mod/contacts.php:667
 msgid ""
 "Replies/likes to your public posts <strong>may</strong> still be visible"
 msgstr ""
 
-#: mod/contacts.php:667
+#: mod/contacts.php:668
 msgid "Notification for new posts"
 msgstr ""
 
-#: mod/contacts.php:667
+#: mod/contacts.php:668
 msgid "Send a notification of every new post of this contact"
 msgstr ""
 
-#: mod/contacts.php:670
+#: mod/contacts.php:671
 msgid "Blacklisted keywords"
 msgstr ""
 
-#: mod/contacts.php:670
+#: mod/contacts.php:671
 msgid ""
 "Comma separated list of keywords that should not be converted to hashtags, "
 "when \"Fetch information and keywords\" is selected"
 msgstr ""
 
-#: mod/contacts.php:682 src/Model/Profile.php:424
+#: mod/contacts.php:683 src/Model/Profile.php:437
 msgid "XMPP:"
 msgstr ""
 
-#: mod/contacts.php:687
+#: mod/contacts.php:688
 msgid "Actions"
 msgstr ""
 
-#: mod/contacts.php:731
+#: mod/contacts.php:734
 msgid "Suggestions"
 msgstr ""
 
-#: mod/contacts.php:734
+#: mod/contacts.php:737
 msgid "Suggest potential friends"
 msgstr ""
 
-#: mod/contacts.php:742
+#: mod/contacts.php:745
 msgid "Show all contacts"
 msgstr ""
 
-#: mod/contacts.php:747
+#: mod/contacts.php:750
 msgid "Unblocked"
 msgstr ""
 
-#: mod/contacts.php:750
+#: mod/contacts.php:753
 msgid "Only show unblocked contacts"
 msgstr ""
 
-#: mod/contacts.php:755
+#: mod/contacts.php:758
 msgid "Blocked"
 msgstr ""
 
-#: mod/contacts.php:758
+#: mod/contacts.php:761
 msgid "Only show blocked contacts"
 msgstr ""
 
-#: mod/contacts.php:763
+#: mod/contacts.php:766
 msgid "Ignored"
 msgstr ""
 
-#: mod/contacts.php:766
+#: mod/contacts.php:769
 msgid "Only show ignored contacts"
 msgstr ""
 
-#: mod/contacts.php:771
+#: mod/contacts.php:774
 msgid "Archived"
 msgstr ""
 
-#: mod/contacts.php:774
+#: mod/contacts.php:777
 msgid "Only show archived contacts"
 msgstr ""
 
-#: mod/contacts.php:779
+#: mod/contacts.php:782
 msgid "Hidden"
 msgstr ""
 
-#: mod/contacts.php:782
+#: mod/contacts.php:785
 msgid "Only show hidden contacts"
 msgstr ""
 
-#: mod/contacts.php:840
+#: mod/contacts.php:843
 msgid "Search your contacts"
 msgstr ""
 
-#: mod/contacts.php:851 mod/contacts.php:1122
+#: mod/contacts.php:854 mod/contacts.php:1125
 msgid "Archive"
 msgstr ""
 
-#: mod/contacts.php:851 mod/contacts.php:1122
+#: mod/contacts.php:854 mod/contacts.php:1125
 msgid "Unarchive"
 msgstr ""
 
-#: mod/contacts.php:854
+#: mod/contacts.php:857
 msgid "Batch Actions"
 msgstr ""
 
-#: mod/contacts.php:880
+#: mod/contacts.php:883
 msgid "Conversations started by this contact"
 msgstr ""
 
-#: mod/contacts.php:885
+#: mod/contacts.php:888
 msgid "Posts and Comments"
 msgstr ""
 
-#: mod/contacts.php:896 src/Model/Profile.php:886
+#: mod/contacts.php:899 src/Model/Profile.php:899
 msgid "Profile Details"
 msgstr ""
 
-#: mod/contacts.php:908
+#: mod/contacts.php:911
 msgid "View all contacts"
 msgstr ""
 
-#: mod/contacts.php:919
+#: mod/contacts.php:922
 msgid "View all common friends"
 msgstr ""
 
-#: mod/contacts.php:929
+#: mod/contacts.php:932
 msgid "Advanced Contact Settings"
 msgstr ""
 
-#: mod/contacts.php:1019
+#: mod/contacts.php:1022
 msgid "Mutual Friendship"
 msgstr ""
 
-#: mod/contacts.php:1024
+#: mod/contacts.php:1027
 msgid "is a fan of yours"
 msgstr ""
 
-#: mod/contacts.php:1029
+#: mod/contacts.php:1032
 msgid "you are a fan of"
 msgstr ""
 
-#: mod/contacts.php:1046 mod/photos.php:1494 mod/photos.php:1533
-#: mod/photos.php:1593 src/Object/Post.php:792
+#: mod/contacts.php:1049 mod/photos.php:1496 mod/photos.php:1535
+#: mod/photos.php:1595 src/Object/Post.php:792
 msgid "This is you"
 msgstr ""
 
-#: mod/contacts.php:1053
+#: mod/contacts.php:1056
 msgid "Edit contact"
 msgstr ""
 
-#: mod/contacts.php:1107
+#: mod/contacts.php:1110
 msgid "Toggle Blocked status"
 msgstr ""
 
-#: mod/contacts.php:1115
+#: mod/contacts.php:1118
 msgid "Toggle Ignored status"
 msgstr ""
 
-#: mod/contacts.php:1124
+#: mod/contacts.php:1127
 msgid "Toggle Archive status"
 msgstr ""
 
-#: mod/contacts.php:1132
+#: mod/contacts.php:1135
 msgid "Delete contact"
 msgstr ""
 
-#: mod/events.php:103 mod/events.php:105
+#: mod/events.php:105 mod/events.php:107
 msgid "Event can not end before it has started."
 msgstr ""
 
-#: mod/events.php:112 mod/events.php:114
+#: mod/events.php:114 mod/events.php:116
 msgid "Event title and start time are required."
 msgstr ""
 
-#: mod/events.php:392
+#: mod/events.php:393
 msgid "Create New Event"
 msgstr ""
 
-#: mod/events.php:509
+#: mod/events.php:516
 msgid "Event details"
 msgstr ""
 
-#: mod/events.php:510
+#: mod/events.php:517
 msgid "Starting date and Title are required."
 msgstr ""
 
-#: mod/events.php:511 mod/events.php:512
+#: mod/events.php:518 mod/events.php:523
 msgid "Event Starts:"
 msgstr ""
 
-#: mod/events.php:511 mod/events.php:523 mod/profiles.php:607
+#: mod/events.php:518 mod/events.php:550 mod/profiles.php:607
 msgid "Required"
 msgstr ""
 
-#: mod/events.php:513 mod/events.php:529
+#: mod/events.php:531 mod/events.php:556
 msgid "Finish date/time is not known or not relevant"
 msgstr ""
 
-#: mod/events.php:515 mod/events.php:516
+#: mod/events.php:533 mod/events.php:538
 msgid "Event Finishes:"
 msgstr ""
 
-#: mod/events.php:517 mod/events.php:530
+#: mod/events.php:544 mod/events.php:557
 msgid "Adjust for viewer timezone"
 msgstr ""
 
-#: mod/events.php:519
+#: mod/events.php:546
 msgid "Description:"
 msgstr ""
 
-#: mod/events.php:523 mod/events.php:525
+#: mod/events.php:550 mod/events.php:552
 msgid "Title:"
 msgstr ""
 
-#: mod/events.php:526 mod/events.php:527
+#: mod/events.php:553 mod/events.php:554
 msgid "Share this event"
 msgstr ""
 
-#: mod/events.php:534 src/Model/Profile.php:851
+#: mod/events.php:561 src/Model/Profile.php:864
 msgid "Basic"
 msgstr ""
 
-#: mod/events.php:536 mod/photos.php:1112 mod/photos.php:1448
+#: mod/events.php:563 mod/photos.php:1114 mod/photos.php:1450
 #: src/Core/ACL.php:307
 msgid "Permissions"
 msgstr ""
 
-#: mod/events.php:555
+#: mod/events.php:579
 msgid "Failed to remove event"
 msgstr ""
 
-#: mod/events.php:557
+#: mod/events.php:581
 msgid "Event removed"
 msgstr ""
 
@@ -6987,8 +7003,8 @@ msgid "The network type couldn't be detected. Contact can't be added."
 msgstr ""
 
 #: mod/fbrowser.php:44 mod/fbrowser.php:69 mod/photos.php:198
-#: mod/photos.php:1076 mod/photos.php:1169 mod/photos.php:1186
-#: mod/photos.php:1652 mod/photos.php:1667 src/Model/Photo.php:243
+#: mod/photos.php:1078 mod/photos.php:1171 mod/photos.php:1188
+#: mod/photos.php:1654 mod/photos.php:1669 src/Model/Photo.php:243
 #: src/Model/Photo.php:252
 msgid "Contact Photos"
 msgstr ""
@@ -7059,7 +7075,7 @@ msgid ""
 "not reflect the opinions of this node’s users."
 msgstr ""
 
-#: mod/localtime.php:19 src/Model/Event.php:34 src/Model/Event.php:829
+#: mod/localtime.php:19 src/Model/Event.php:35 src/Model/Event.php:836
 msgid "l F d, Y \\@ g:i A"
 msgstr ""
 
@@ -7092,23 +7108,23 @@ msgstr ""
 msgid "Please select your timezone:"
 msgstr ""
 
-#: mod/poke.php:188
+#: mod/poke.php:187
 msgid "Poke/Prod"
 msgstr ""
 
-#: mod/poke.php:189
+#: mod/poke.php:188
 msgid "poke, prod or do other things to somebody"
 msgstr ""
 
-#: mod/poke.php:190
+#: mod/poke.php:189
 msgid "Recipient"
 msgstr ""
 
-#: mod/poke.php:191
+#: mod/poke.php:190
 msgid "Choose what you wish to do to recipient"
 msgstr ""
 
-#: mod/poke.php:194
+#: mod/poke.php:193
 msgid "Make this post private"
 msgstr ""
 
@@ -7216,7 +7232,7 @@ msgid ""
 "important, please visit http://friendi.ca"
 msgstr ""
 
-#: mod/notes.php:42 src/Model/Profile.php:933
+#: mod/notes.php:42 src/Model/Profile.php:946
 msgid "Personal Notes"
 msgstr ""
 
@@ -7320,7 +7336,7 @@ msgstr ""
 msgid "View all profiles"
 msgstr ""
 
-#: mod/profiles.php:582 mod/profiles.php:677 src/Model/Profile.php:393
+#: mod/profiles.php:582 mod/profiles.php:677 src/Model/Profile.php:406
 msgid "Edit visibility"
 msgstr ""
 
@@ -7372,7 +7388,7 @@ msgstr ""
 msgid "<span class=\"heart\">&hearts;</span> Marital Status:"
 msgstr ""
 
-#: mod/profiles.php:601 src/Model/Profile.php:769
+#: mod/profiles.php:601 src/Model/Profile.php:782
 msgid "Sexual Preference:"
 msgstr ""
 
@@ -7452,11 +7468,11 @@ msgstr ""
 msgid "Homepage URL:"
 msgstr ""
 
-#: mod/profiles.php:628 src/Model/Profile.php:777
+#: mod/profiles.php:628 src/Model/Profile.php:790
 msgid "Hometown:"
 msgstr ""
 
-#: mod/profiles.php:629 src/Model/Profile.php:785
+#: mod/profiles.php:629 src/Model/Profile.php:798
 msgid "Political Views:"
 msgstr ""
 
@@ -7480,11 +7496,11 @@ msgstr ""
 msgid "(Used for searching profiles, never shown to others)"
 msgstr ""
 
-#: mod/profiles.php:633 src/Model/Profile.php:801
+#: mod/profiles.php:633 src/Model/Profile.php:814
 msgid "Likes:"
 msgstr ""
 
-#: mod/profiles.php:634 src/Model/Profile.php:805
+#: mod/profiles.php:634 src/Model/Profile.php:818
 msgid "Dislikes:"
 msgstr ""
 
@@ -7524,11 +7540,11 @@ msgstr ""
 msgid "Contact information and Social Networks"
 msgstr ""
 
-#: mod/profiles.php:674 src/Model/Profile.php:389
+#: mod/profiles.php:674 src/Model/Profile.php:402
 msgid "Profile Image"
 msgstr ""
 
-#: mod/profiles.php:676 src/Model/Profile.php:392
+#: mod/profiles.php:676 src/Model/Profile.php:405
 msgid "visible to everybody"
 msgstr ""
 
@@ -7536,23 +7552,23 @@ msgstr ""
 msgid "Edit/Manage Profiles"
 msgstr ""
 
-#: mod/profiles.php:684 src/Model/Profile.php:379 src/Model/Profile.php:401
+#: mod/profiles.php:684 src/Model/Profile.php:392 src/Model/Profile.php:414
 msgid "Change profile photo"
 msgstr ""
 
-#: mod/profiles.php:685 src/Model/Profile.php:380
+#: mod/profiles.php:685 src/Model/Profile.php:393
 msgid "Create New Profile"
 msgstr ""
 
-#: mod/photos.php:112 src/Model/Profile.php:894
+#: mod/photos.php:112 src/Model/Profile.php:907
 msgid "Photo Albums"
 msgstr ""
 
-#: mod/photos.php:113 mod/photos.php:1708
+#: mod/photos.php:113 mod/photos.php:1710
 msgid "Recent Photos"
 msgstr ""
 
-#: mod/photos.php:116 mod/photos.php:1230 mod/photos.php:1710
+#: mod/photos.php:116 mod/photos.php:1232 mod/photos.php:1712
 msgid "Upload New Photos"
 msgstr ""
 
@@ -7564,7 +7580,7 @@ msgstr ""
 msgid "Album not found."
 msgstr ""
 
-#: mod/photos.php:239 mod/photos.php:252 mod/photos.php:1181
+#: mod/photos.php:239 mod/photos.php:252 mod/photos.php:1183
 msgid "Delete Album"
 msgstr ""
 
@@ -7572,7 +7588,7 @@ msgstr ""
 msgid "Do you really want to delete this photo album and all its photos?"
 msgstr ""
 
-#: mod/photos.php:312 mod/photos.php:324 mod/photos.php:1453
+#: mod/photos.php:312 mod/photos.php:324 mod/photos.php:1455
 msgid "Delete Photo"
 msgstr ""
 
@@ -7589,149 +7605,149 @@ msgstr ""
 msgid "%1$s was tagged in %2$s by %3$s"
 msgstr ""
 
-#: mod/photos.php:782
+#: mod/photos.php:784
 msgid "Image upload didn't complete, please try again"
 msgstr ""
 
-#: mod/photos.php:785
+#: mod/photos.php:787
 msgid "Image file is missing"
 msgstr ""
 
-#: mod/photos.php:790
+#: mod/photos.php:792
 msgid ""
 "Server can't accept new file upload at this time, please contact your "
 "administrator"
 msgstr ""
 
-#: mod/photos.php:816
+#: mod/photos.php:818
 msgid "Image file is empty."
 msgstr ""
 
-#: mod/photos.php:953
+#: mod/photos.php:955
 msgid "No photos selected"
 msgstr ""
 
-#: mod/photos.php:1104
+#: mod/photos.php:1106
 msgid "Upload Photos"
 msgstr ""
 
-#: mod/photos.php:1108 mod/photos.php:1176
+#: mod/photos.php:1110 mod/photos.php:1178
 msgid "New album name: "
 msgstr ""
 
-#: mod/photos.php:1109
+#: mod/photos.php:1111
 msgid "or select existing album:"
 msgstr ""
 
-#: mod/photos.php:1110
+#: mod/photos.php:1112
 msgid "Do not show a status post for this upload"
 msgstr ""
 
-#: mod/photos.php:1187
+#: mod/photos.php:1189
 msgid "Edit Album"
 msgstr ""
 
-#: mod/photos.php:1192
+#: mod/photos.php:1194
 msgid "Show Newest First"
 msgstr ""
 
-#: mod/photos.php:1194
+#: mod/photos.php:1196
 msgid "Show Oldest First"
 msgstr ""
 
-#: mod/photos.php:1215 mod/photos.php:1693
+#: mod/photos.php:1217 mod/photos.php:1695
 msgid "View Photo"
 msgstr ""
 
-#: mod/photos.php:1256
+#: mod/photos.php:1258
 msgid "Permission denied. Access to this item may be restricted."
 msgstr ""
 
-#: mod/photos.php:1258
+#: mod/photos.php:1260
 msgid "Photo not available"
 msgstr ""
 
-#: mod/photos.php:1333
+#: mod/photos.php:1335
 msgid "View photo"
 msgstr ""
 
-#: mod/photos.php:1333
+#: mod/photos.php:1335
 msgid "Edit photo"
 msgstr ""
 
-#: mod/photos.php:1334
+#: mod/photos.php:1336
 msgid "Use as profile photo"
 msgstr ""
 
-#: mod/photos.php:1340 src/Object/Post.php:151
+#: mod/photos.php:1342 src/Object/Post.php:151
 msgid "Private Message"
 msgstr ""
 
-#: mod/photos.php:1360
+#: mod/photos.php:1362
 msgid "View Full Size"
 msgstr ""
 
-#: mod/photos.php:1421
+#: mod/photos.php:1423
 msgid "Tags: "
 msgstr ""
 
-#: mod/photos.php:1424
+#: mod/photos.php:1426
 msgid "[Remove any tag]"
 msgstr ""
 
-#: mod/photos.php:1439
+#: mod/photos.php:1441
 msgid "New album name"
 msgstr ""
 
-#: mod/photos.php:1440
+#: mod/photos.php:1442
 msgid "Caption"
 msgstr ""
 
-#: mod/photos.php:1441
+#: mod/photos.php:1443
 msgid "Add a Tag"
 msgstr ""
 
-#: mod/photos.php:1441
+#: mod/photos.php:1443
 msgid "Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping"
 msgstr ""
 
-#: mod/photos.php:1442
+#: mod/photos.php:1444
 msgid "Do not rotate"
 msgstr ""
 
-#: mod/photos.php:1443
+#: mod/photos.php:1445
 msgid "Rotate CW (right)"
 msgstr ""
 
-#: mod/photos.php:1444
+#: mod/photos.php:1446
 msgid "Rotate CCW (left)"
 msgstr ""
 
-#: mod/photos.php:1478 src/Object/Post.php:293
+#: mod/photos.php:1480 src/Object/Post.php:293
 msgid "I like this (toggle)"
 msgstr ""
 
-#: mod/photos.php:1479 src/Object/Post.php:294
+#: mod/photos.php:1481 src/Object/Post.php:294
 msgid "I don't like this (toggle)"
 msgstr ""
 
-#: mod/photos.php:1496 mod/photos.php:1535 mod/photos.php:1595
+#: mod/photos.php:1498 mod/photos.php:1537 mod/photos.php:1597
 #: src/Object/Post.php:398 src/Object/Post.php:794
 msgid "Comment"
 msgstr ""
 
-#: mod/photos.php:1627
+#: mod/photos.php:1629
 msgid "Map"
 msgstr ""
 
-#: local/test.php:1840
+#: local/test.php:1919
 #, php-format
 msgid ""
 "<span><a href=\"%s\" target=\"_blank\" class=\"shared-wall-item-name\">%s</"
 "a> wrote the following <a href=\"%s\" target=\"_blank\">post</a>"
 msgstr ""
 
-#: local/testshare.php:158 src/Content/Text/BBCode.php:991
+#: local/testshare.php:158 src/Content/Text/BBCode.php:992
 #, php-format
 msgid "<a href=\"%1$s\" target=\"_blank\">%2$s</a> %3$s"
 msgstr ""
@@ -7793,11 +7809,11 @@ msgstr ""
 msgid "%s: updating %s table."
 msgstr ""
 
-#: src/Core/Install.php:138
+#: src/Core/Install.php:139
 msgid "Could not find a command line version of PHP in the web server PATH."
 msgstr ""
 
-#: src/Core/Install.php:139
+#: src/Core/Install.php:140
 msgid ""
 "If you don't have a command line version of PHP installed on your server, "
 "you will not be able to run the background processing. See <a href='https://"
@@ -7805,219 +7821,219 @@ msgid ""
 "worker'>'Setup the worker'</a>"
 msgstr ""
 
-#: src/Core/Install.php:143
+#: src/Core/Install.php:144
 msgid "PHP executable path"
 msgstr ""
 
-#: src/Core/Install.php:143
+#: src/Core/Install.php:144
 msgid ""
 "Enter full path to php executable. You can leave this blank to continue the "
 "installation."
 msgstr ""
 
-#: src/Core/Install.php:148
+#: src/Core/Install.php:149
 msgid "Command line PHP"
 msgstr ""
 
-#: src/Core/Install.php:157
+#: src/Core/Install.php:158
 msgid "PHP executable is not the php cli binary (could be cgi-fgci version)"
 msgstr ""
 
-#: src/Core/Install.php:158
+#: src/Core/Install.php:159
 msgid "Found PHP version: "
 msgstr ""
 
-#: src/Core/Install.php:160
+#: src/Core/Install.php:161
 msgid "PHP cli binary"
 msgstr ""
 
-#: src/Core/Install.php:170
+#: src/Core/Install.php:171
 msgid ""
 "The command line version of PHP on your system does not have "
 "\"register_argc_argv\" enabled."
 msgstr ""
 
-#: src/Core/Install.php:171
+#: src/Core/Install.php:172
 msgid "This is required for message delivery to work."
 msgstr ""
 
-#: src/Core/Install.php:173
+#: src/Core/Install.php:174
 msgid "PHP register_argc_argv"
 msgstr ""
 
-#: src/Core/Install.php:201
+#: src/Core/Install.php:202
 msgid ""
 "Error: the \"openssl_pkey_new\" function on this system is not able to "
 "generate encryption keys"
 msgstr ""
 
-#: src/Core/Install.php:202
+#: src/Core/Install.php:203
 msgid ""
 "If running under Windows, please see \"http://www.php.net/manual/en/openssl."
 "installation.php\"."
 msgstr ""
 
-#: src/Core/Install.php:204
+#: src/Core/Install.php:205
 msgid "Generate encryption keys"
 msgstr ""
 
-#: src/Core/Install.php:225
+#: src/Core/Install.php:226
 msgid "libCurl PHP module"
 msgstr ""
 
-#: src/Core/Install.php:226
+#: src/Core/Install.php:227
 msgid "GD graphics PHP module"
 msgstr ""
 
-#: src/Core/Install.php:227
+#: src/Core/Install.php:228
 msgid "OpenSSL PHP module"
 msgstr ""
 
-#: src/Core/Install.php:228
+#: src/Core/Install.php:229
 msgid "PDO or MySQLi PHP module"
 msgstr ""
 
-#: src/Core/Install.php:229
+#: src/Core/Install.php:230
 msgid "mb_string PHP module"
 msgstr ""
 
-#: src/Core/Install.php:230
+#: src/Core/Install.php:231
 msgid "XML PHP module"
 msgstr ""
 
-#: src/Core/Install.php:231
+#: src/Core/Install.php:232
 msgid "iconv PHP module"
 msgstr ""
 
-#: src/Core/Install.php:232
+#: src/Core/Install.php:233
 msgid "POSIX PHP module"
 msgstr ""
 
-#: src/Core/Install.php:236 src/Core/Install.php:238
+#: src/Core/Install.php:237 src/Core/Install.php:239
 msgid "Apache mod_rewrite module"
 msgstr ""
 
-#: src/Core/Install.php:236
+#: src/Core/Install.php:237
 msgid ""
 "Error: Apache webserver mod-rewrite module is required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:244
+#: src/Core/Install.php:245
 msgid "Error: libCURL PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:248
+#: src/Core/Install.php:249
 msgid ""
 "Error: GD graphics PHP module with JPEG support required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:252
+#: src/Core/Install.php:253
 msgid "Error: openssl PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:256
+#: src/Core/Install.php:257
 msgid "Error: PDO or MySQLi PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:260
+#: src/Core/Install.php:261
 msgid "Error: The MySQL driver for PDO is not installed."
 msgstr ""
 
-#: src/Core/Install.php:264
+#: src/Core/Install.php:265
 msgid "Error: mb_string PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:268
+#: src/Core/Install.php:269
 msgid "Error: iconv PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:272
+#: src/Core/Install.php:273
 msgid "Error: POSIX PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:282
+#: src/Core/Install.php:283
 msgid "Error, XML PHP module required but not installed."
 msgstr ""
 
-#: src/Core/Install.php:301
+#: src/Core/Install.php:302
 msgid ""
 "The web installer needs to be able to create a file called \"local.ini.php\" "
 "in the \"config\" folder of your web server and it is unable to do so."
 msgstr ""
 
-#: src/Core/Install.php:302
+#: src/Core/Install.php:303
 msgid ""
 "This is most often a permission setting, as the web server may not be able "
 "to write files in your folder - even if you can."
 msgstr ""
 
-#: src/Core/Install.php:303
+#: src/Core/Install.php:304
 msgid ""
 "At the end of this procedure, we will give you a text to save in a file "
 "named local.ini.php in your Friendica \"config\" folder."
 msgstr ""
 
-#: src/Core/Install.php:304
+#: src/Core/Install.php:305
 msgid ""
 "You can alternatively skip this procedure and perform a manual installation. "
 "Please see the file \"INSTALL.txt\" for instructions."
 msgstr ""
 
-#: src/Core/Install.php:307
+#: src/Core/Install.php:308
 msgid "config/local.ini.php is writable"
 msgstr ""
 
-#: src/Core/Install.php:325
+#: src/Core/Install.php:326
 msgid ""
 "Friendica uses the Smarty3 template engine to render its web views. Smarty3 "
 "compiles templates to PHP to speed up rendering."
 msgstr ""
 
-#: src/Core/Install.php:326
+#: src/Core/Install.php:327
 msgid ""
 "In order to store these compiled templates, the web server needs to have "
 "write access to the directory view/smarty3/ under the Friendica top level "
 "folder."
 msgstr ""
 
-#: src/Core/Install.php:327
+#: src/Core/Install.php:328
 msgid ""
 "Please ensure that the user that your web server runs as (e.g. www-data) has "
 "write access to this folder."
 msgstr ""
 
-#: src/Core/Install.php:328
+#: src/Core/Install.php:329
 msgid ""
 "Note: as a security measure, you should give the web server write access to "
 "view/smarty3/ only--not the template files (.tpl) that it contains."
 msgstr ""
 
-#: src/Core/Install.php:331
+#: src/Core/Install.php:332
 msgid "view/smarty3 is writable"
 msgstr ""
 
-#: src/Core/Install.php:356
+#: src/Core/Install.php:357
 msgid ""
 "Url rewrite in .htaccess is not working. Check your server configuration."
 msgstr ""
 
-#: src/Core/Install.php:358
+#: src/Core/Install.php:359
 msgid "Error message from Curl when fetching"
 msgstr ""
 
-#: src/Core/Install.php:362
+#: src/Core/Install.php:363
 msgid "Url rewrite is working"
 msgstr ""
 
-#: src/Core/Install.php:389
+#: src/Core/Install.php:390
 msgid "ImageMagick PHP extension is not installed"
 msgstr ""
 
-#: src/Core/Install.php:391
+#: src/Core/Install.php:392
 msgid "ImageMagick PHP extension is installed"
 msgstr ""
 
-#: src/Core/Install.php:393
+#: src/Core/Install.php:394
 msgid "ImageMagick supports GIF"
 msgstr ""
 
@@ -8051,11 +8067,16 @@ msgstr ""
 msgid "The contact entries have been archived"
 msgstr ""
 
-#: src/Core/Console/PostUpdate.php:32
+#: src/Core/Console/PostUpdate.php:49
+#, php-format
+msgid "Post update version number has been set to %s."
+msgstr ""
+
+#: src/Core/Console/PostUpdate.php:57
 msgid "Execute pending post updates."
 msgstr ""
 
-#: src/Core/Console/PostUpdate.php:38
+#: src/Core/Console/PostUpdate.php:63
 msgid "All pending post updates are done."
 msgstr ""
 
@@ -8115,20 +8136,20 @@ msgstr ""
 msgid "%s may attend %s's event"
 msgstr ""
 
-#: src/Core/NotificationsManager.php:360
+#: src/Core/NotificationsManager.php:372
 #, php-format
 msgid "%s is now friends with %s"
 msgstr ""
 
-#: src/Core/NotificationsManager.php:626
+#: src/Core/NotificationsManager.php:638
 msgid "Friend Suggestion"
 msgstr ""
 
-#: src/Core/NotificationsManager.php:656
+#: src/Core/NotificationsManager.php:672
 msgid "Friend/Connect Request"
 msgstr ""
 
-#: src/Core/NotificationsManager.php:656
+#: src/Core/NotificationsManager.php:672
 msgid "New Follower"
 msgstr ""
 
@@ -8164,7 +8185,7 @@ msgstr[1] ""
 msgid "Done. You can now login with your username and password"
 msgstr ""
 
-#: src/Worker/Delivery.php:423
+#: src/Worker/Delivery.php:425
 msgid "(no subject)"
 msgstr ""
 
@@ -8299,15 +8320,15 @@ msgstr ""
 msgid "Video"
 msgstr ""
 
-#: src/App.php:785
+#: src/App.php:798
 msgid "Delete this item?"
 msgstr ""
 
-#: src/App.php:787
+#: src/App.php:800
 msgid "show fewer"
 msgstr ""
 
-#: src/App.php:1385
+#: src/App.php:1416
 msgid "No system theme config value set."
 msgstr ""
 
@@ -8395,43 +8416,47 @@ msgstr ""
 msgid "Privacy Statement"
 msgstr ""
 
-#: src/Protocol/OStatus.php:1813
+#: src/Module/Proxy.php:138
+msgid "Bad Request."
+msgstr ""
+
+#: src/Protocol/OStatus.php:1823
 #, php-format
 msgid "%s is now following %s."
 msgstr ""
 
-#: src/Protocol/OStatus.php:1814
+#: src/Protocol/OStatus.php:1824
 msgid "following"
 msgstr ""
 
-#: src/Protocol/OStatus.php:1817
+#: src/Protocol/OStatus.php:1827
 #, php-format
 msgid "%s stopped following %s."
 msgstr ""
 
-#: src/Protocol/OStatus.php:1818
+#: src/Protocol/OStatus.php:1828
 msgid "stopped following"
 msgstr ""
 
-#: src/Protocol/DFRN.php:1525 src/Model/Contact.php:1956
+#: src/Protocol/DFRN.php:1528 src/Model/Contact.php:1974
 #, php-format
 msgid "%s's birthday"
 msgstr ""
 
-#: src/Protocol/DFRN.php:1526 src/Model/Contact.php:1957
+#: src/Protocol/DFRN.php:1529 src/Model/Contact.php:1975
 #, php-format
 msgid "Happy Birthday %s"
 msgstr ""
 
-#: src/Protocol/Diaspora.php:2417
+#: src/Protocol/Diaspora.php:2434
 msgid "Sharing notification from Diaspora network"
 msgstr ""
 
-#: src/Protocol/Diaspora.php:3514
+#: src/Protocol/Diaspora.php:3531
 msgid "Attachments:"
 msgstr ""
 
-#: src/Util/Temporal.php:147 src/Model/Profile.php:745
+#: src/Util/Temporal.php:147 src/Model/Profile.php:758
 msgid "Birthday:"
 msgstr ""
 
@@ -8500,134 +8525,134 @@ msgstr ""
 msgid "[no subject]"
 msgstr ""
 
-#: src/Model/Contact.php:942
+#: src/Model/Contact.php:953
 msgid "Drop Contact"
 msgstr ""
 
-#: src/Model/Contact.php:1399
+#: src/Model/Contact.php:1408
 msgid "Organisation"
 msgstr ""
 
-#: src/Model/Contact.php:1403
+#: src/Model/Contact.php:1412
 msgid "News"
 msgstr ""
 
-#: src/Model/Contact.php:1407
+#: src/Model/Contact.php:1416
 msgid "Forum"
 msgstr ""
 
-#: src/Model/Contact.php:1587
+#: src/Model/Contact.php:1598
 msgid "Connect URL missing."
 msgstr ""
 
-#: src/Model/Contact.php:1596
+#: src/Model/Contact.php:1607
 msgid ""
 "The contact could not be added. Please check the relevant network "
 "credentials in your Settings -> Social Networks page."
 msgstr ""
 
-#: src/Model/Contact.php:1635
+#: src/Model/Contact.php:1646
 msgid ""
 "This site is not configured to allow communications with other networks."
 msgstr ""
 
-#: src/Model/Contact.php:1636 src/Model/Contact.php:1650
+#: src/Model/Contact.php:1647 src/Model/Contact.php:1661
 msgid "No compatible communication protocols or feeds were discovered."
 msgstr ""
 
-#: src/Model/Contact.php:1648
+#: src/Model/Contact.php:1659
 msgid "The profile address specified does not provide adequate information."
 msgstr ""
 
-#: src/Model/Contact.php:1653
+#: src/Model/Contact.php:1664
 msgid "An author or name was not found."
 msgstr ""
 
-#: src/Model/Contact.php:1656
+#: src/Model/Contact.php:1667
 msgid "No browser URL could be matched to this address."
 msgstr ""
 
-#: src/Model/Contact.php:1659
+#: src/Model/Contact.php:1670
 msgid ""
 "Unable to match @-style Identity Address with a known protocol or email "
 "contact."
 msgstr ""
 
-#: src/Model/Contact.php:1660
+#: src/Model/Contact.php:1671
 msgid "Use mailto: in front of address to force email check."
 msgstr ""
 
-#: src/Model/Contact.php:1666
+#: src/Model/Contact.php:1677
 msgid ""
 "The profile address specified belongs to a network which has been disabled "
 "on this site."
 msgstr ""
 
-#: src/Model/Contact.php:1671
+#: src/Model/Contact.php:1682
 msgid ""
 "Limited profile. This person will be unable to receive direct/personal "
 "notifications from you."
 msgstr ""
 
-#: src/Model/Contact.php:1722
+#: src/Model/Contact.php:1733
 msgid "Unable to retrieve contact information."
 msgstr ""
 
-#: src/Model/Event.php:59 src/Model/Event.php:76 src/Model/Event.php:428
-#: src/Model/Event.php:897
+#: src/Model/Event.php:60 src/Model/Event.php:77 src/Model/Event.php:429
+#: src/Model/Event.php:904
 msgid "Starts:"
 msgstr ""
 
-#: src/Model/Event.php:62 src/Model/Event.php:82 src/Model/Event.php:429
-#: src/Model/Event.php:901
+#: src/Model/Event.php:63 src/Model/Event.php:83 src/Model/Event.php:430
+#: src/Model/Event.php:908
 msgid "Finishes:"
 msgstr ""
 
-#: src/Model/Event.php:377
+#: src/Model/Event.php:378
 msgid "all-day"
 msgstr ""
 
-#: src/Model/Event.php:400
+#: src/Model/Event.php:401
 msgid "Jun"
 msgstr ""
 
-#: src/Model/Event.php:403
+#: src/Model/Event.php:404
 msgid "Sept"
 msgstr ""
 
-#: src/Model/Event.php:426
+#: src/Model/Event.php:427
 msgid "No events to display"
 msgstr ""
 
-#: src/Model/Event.php:550
+#: src/Model/Event.php:551
 msgid "l, F j"
 msgstr ""
 
-#: src/Model/Event.php:581
+#: src/Model/Event.php:582
 msgid "Edit event"
 msgstr ""
 
-#: src/Model/Event.php:582
+#: src/Model/Event.php:583
 msgid "Duplicate event"
 msgstr ""
 
-#: src/Model/Event.php:583
+#: src/Model/Event.php:584
 msgid "Delete event"
 msgstr ""
 
-#: src/Model/Event.php:830
+#: src/Model/Event.php:837
 msgid "D g:i A"
 msgstr ""
 
-#: src/Model/Event.php:831
+#: src/Model/Event.php:838
 msgid "g:i A"
 msgstr ""
 
-#: src/Model/Event.php:916 src/Model/Event.php:918
+#: src/Model/Event.php:923 src/Model/Event.php:925
 msgid "Show map"
 msgstr ""
 
-#: src/Model/Event.php:917
+#: src/Model/Event.php:924
 msgid "Hide map"
 msgstr ""
 
@@ -8707,7 +8732,7 @@ msgstr ""
 msgid "An error occurred creating your self contact. Please try again."
 msgstr ""
 
-#: src/Model/User.php:561 src/Content/ContactSelector.php:166
+#: src/Model/User.php:561 src/Content/ContactSelector.php:171
 msgid "Friends"
 msgstr ""
 
@@ -8810,129 +8835,129 @@ msgstr ""
 msgid "Edit groups"
 msgstr ""
 
-#: src/Model/Profile.php:97
+#: src/Model/Profile.php:110
 msgid "Requested account is not available."
 msgstr ""
 
-#: src/Model/Profile.php:163 src/Model/Profile.php:399
-#: src/Model/Profile.php:846
+#: src/Model/Profile.php:176 src/Model/Profile.php:412
+#: src/Model/Profile.php:859
 msgid "Edit profile"
 msgstr ""
 
-#: src/Model/Profile.php:333
+#: src/Model/Profile.php:346
 msgid "Atom feed"
 msgstr ""
 
-#: src/Model/Profile.php:372
+#: src/Model/Profile.php:385
 msgid "Manage/edit profiles"
 msgstr ""
 
-#: src/Model/Profile.php:550 src/Model/Profile.php:639
+#: src/Model/Profile.php:563 src/Model/Profile.php:652
 msgid "g A l F d"
 msgstr ""
 
-#: src/Model/Profile.php:551
+#: src/Model/Profile.php:564
 msgid "F d"
 msgstr ""
 
-#: src/Model/Profile.php:604 src/Model/Profile.php:690
+#: src/Model/Profile.php:617 src/Model/Profile.php:703
 msgid "[today]"
 msgstr ""
 
-#: src/Model/Profile.php:615
+#: src/Model/Profile.php:628
 msgid "Birthday Reminders"
 msgstr ""
 
-#: src/Model/Profile.php:616
+#: src/Model/Profile.php:629
 msgid "Birthdays this week:"
 msgstr ""
 
-#: src/Model/Profile.php:677
+#: src/Model/Profile.php:690
 msgid "[No description]"
 msgstr ""
 
-#: src/Model/Profile.php:704
+#: src/Model/Profile.php:717
 msgid "Event Reminders"
 msgstr ""
 
-#: src/Model/Profile.php:705
+#: src/Model/Profile.php:718
 msgid "Upcoming events the next 7 days:"
 msgstr ""
 
-#: src/Model/Profile.php:728
+#: src/Model/Profile.php:741
 msgid "Member since:"
 msgstr ""
 
-#: src/Model/Profile.php:736
+#: src/Model/Profile.php:749
 msgid "j F, Y"
 msgstr ""
 
-#: src/Model/Profile.php:737
+#: src/Model/Profile.php:750
 msgid "j F"
 msgstr ""
 
-#: src/Model/Profile.php:752
+#: src/Model/Profile.php:765
 msgid "Age:"
 msgstr ""
 
-#: src/Model/Profile.php:765
+#: src/Model/Profile.php:778
 #, php-format
 msgid "for %1$d %2$s"
 msgstr ""
 
-#: src/Model/Profile.php:789
+#: src/Model/Profile.php:802
 msgid "Religion:"
 msgstr ""
 
-#: src/Model/Profile.php:797
+#: src/Model/Profile.php:810
 msgid "Hobbies/Interests:"
 msgstr ""
 
-#: src/Model/Profile.php:809
+#: src/Model/Profile.php:822
 msgid "Contact information and Social Networks:"
 msgstr ""
 
-#: src/Model/Profile.php:813
+#: src/Model/Profile.php:826
 msgid "Musical interests:"
 msgstr ""
 
-#: src/Model/Profile.php:817
+#: src/Model/Profile.php:830
 msgid "Books, literature:"
 msgstr ""
 
-#: src/Model/Profile.php:821
+#: src/Model/Profile.php:834
 msgid "Television:"
 msgstr ""
 
-#: src/Model/Profile.php:825
+#: src/Model/Profile.php:838
 msgid "Film/dance/culture/entertainment:"
 msgstr ""
 
-#: src/Model/Profile.php:829
+#: src/Model/Profile.php:842
 msgid "Love/Romance:"
 msgstr ""
 
-#: src/Model/Profile.php:833
+#: src/Model/Profile.php:846
 msgid "Work/employment:"
 msgstr ""
 
-#: src/Model/Profile.php:837
+#: src/Model/Profile.php:850
 msgid "School/education:"
 msgstr ""
 
-#: src/Model/Profile.php:842
+#: src/Model/Profile.php:855
 msgid "Forums:"
 msgstr ""
 
-#: src/Model/Profile.php:936
+#: src/Model/Profile.php:949
 msgid "Only You Can See This"
 msgstr ""
 
-#: src/Model/Profile.php:944 src/Model/Profile.php:947
+#: src/Model/Profile.php:957 src/Model/Profile.php:960
 msgid "Tips for New Members"
 msgstr ""
 
-#: src/Model/Profile.php:1106
+#: src/Model/Profile.php:1119
 #, php-format
 msgid "OpenWebAuth: %1$s welcomes %2$s"
 msgstr ""
@@ -8956,27 +8981,27 @@ msgid_plural "%d invitations available"
 msgstr[0] ""
 msgstr[1] ""
 
-#: src/Content/Widget.php:157
+#: src/Content/Widget.php:154
 msgid "Networks"
 msgstr ""
 
-#: src/Content/Widget.php:160
+#: src/Content/Widget.php:157
 msgid "All Networks"
 msgstr ""
 
-#: src/Content/Widget.php:198 src/Content/Feature.php:118
+#: src/Content/Widget.php:195 src/Content/Feature.php:118
 msgid "Saved Folders"
 msgstr ""
 
-#: src/Content/Widget.php:201 src/Content/Widget.php:241
+#: src/Content/Widget.php:198 src/Content/Widget.php:238
 msgid "Everything"
 msgstr ""
 
-#: src/Content/Widget.php:238
+#: src/Content/Widget.php:235
 msgid "Categories"
 msgstr ""
 
-#: src/Content/Widget.php:305
+#: src/Content/Widget.php:302
 #, php-format
 msgid "%d contact in common"
 msgid_plural "%d contacts in common"
@@ -9052,230 +9077,234 @@ msgid "GNU Social Connector"
 msgstr ""
 
 #: src/Content/ContactSelector.php:92
+msgid "ActivityPub"
+msgstr ""
+
+#: src/Content/ContactSelector.php:93
 msgid "pnut"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Male"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Female"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Currently Male"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Currently Female"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Mostly Male"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Mostly Female"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Transgender"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Intersex"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Transsexual"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Hermaphrodite"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Neuter"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Non-specific"
 msgstr ""
 
-#: src/Content/ContactSelector.php:122
+#: src/Content/ContactSelector.php:127
 msgid "Other"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Males"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Females"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Gay"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Lesbian"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "No Preference"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Bisexual"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Autosexual"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Abstinent"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Virgin"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Deviant"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Fetish"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Oodles"
 msgstr ""
 
-#: src/Content/ContactSelector.php:144
+#: src/Content/ContactSelector.php:149
 msgid "Nonsexual"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Single"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Lonely"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Available"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Unavailable"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Has crush"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Infatuated"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Dating"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Unfaithful"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Sex Addict"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Friends/Benefits"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Casual"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Engaged"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Married"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Imaginarily married"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Partners"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Cohabiting"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Common law"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Happy"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Not looking"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Swinger"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Betrayed"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Separated"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Unstable"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Divorced"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Imaginarily divorced"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Widowed"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Uncertain"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "It's complicated"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Don't care"
 msgstr ""
 
-#: src/Content/ContactSelector.php:166
+#: src/Content/ContactSelector.php:171
 msgid "Ask me"
 msgstr ""
 
@@ -9622,27 +9651,27 @@ msgstr ""
 msgid "Embedded content"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:423
+#: src/Content/Text/BBCode.php:422
 msgid "view full size"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:853 src/Content/Text/BBCode.php:1626
-#: src/Content/Text/BBCode.php:1627
+#: src/Content/Text/BBCode.php:854 src/Content/Text/BBCode.php:1623
+#: src/Content/Text/BBCode.php:1624
 msgid "Image/photo"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1553 src/Content/Text/BBCode.php:1575
+#: src/Content/Text/BBCode.php:1550 src/Content/Text/BBCode.php:1572
 msgid "$1 wrote:"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1635 src/Content/Text/BBCode.php:1636
+#: src/Content/Text/BBCode.php:1632 src/Content/Text/BBCode.php:1633
 msgid "Encrypted content"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1755
+#: src/Content/Text/BBCode.php:1752
 msgid "Invalid source protocol"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1766
+#: src/Content/Text/BBCode.php:1763
 msgid "Invalid link protocol"
 msgstr ""