diff --git a/database.sql b/database.sql index acb9a861de..ac253c9e7a 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2024.09-dev (Yellow Archangel) --- DB_UPDATE_VERSION 1571 +-- DB_UPDATE_VERSION 1572 -- ------------------------------------------ @@ -373,6 +373,7 @@ CREATE TABLE IF NOT EXISTS `apcontact` ( `manually-approve` boolean COMMENT '', `discoverable` boolean COMMENT 'Mastodon extension: true if profile is published in their directory', `suspended` boolean COMMENT 'Mastodon extension: true if profile is suspended', + `posting-restricted` boolean COMMENT 'lemmy:postingRestrictedToMods', `nick` varchar(255) NOT NULL DEFAULT '' COMMENT '', `name` varchar(255) COMMENT '', `about` text COMMENT '', @@ -3673,6 +3674,7 @@ CREATE VIEW `account-view` AS SELECT `apcontact`.`outbox` AS `ap-outbox`, `apcontact`.`sharedinbox` AS `ap-sharedinbox`, `apcontact`.`generator` AS `ap-generator`, + `apcontact`.`posting-restricted` AS `ap-posting-restricted`, `apcontact`.`following_count` AS `ap-following_count`, `apcontact`.`followers_count` AS `ap-followers_count`, `apcontact`.`statuses_count` AS `ap-statuses_count`, @@ -3779,6 +3781,7 @@ CREATE VIEW `account-user-view` AS SELECT `apcontact`.`outbox` AS `ap-outbox`, `apcontact`.`sharedinbox` AS `ap-sharedinbox`, `apcontact`.`generator` AS `ap-generator`, + `apcontact`.`posting-restricted` AS `ap-posting-restricted`, `apcontact`.`following_count` AS `ap-following_count`, `apcontact`.`followers_count` AS `ap-followers_count`, `apcontact`.`statuses_count` AS `ap-statuses_count`, diff --git a/doc/database/db_apcontact.md b/doc/database/db_apcontact.md index 1632378ea8..902d41ae6b 100644 --- a/doc/database/db_apcontact.md +++ b/doc/database/db_apcontact.md @@ -6,40 +6,41 @@ ActivityPub compatible contacts - used in the ActivityPub implementation Fields ------ -| Field | Description | Type | Null | Key | Default | Extra | -| ---------------- | ------------------------------------------------------------------- | -------------- | ---- | --- | ------------------- | ----- | -| url | URL of the contact | varbinary(383) | NO | PRI | NULL | | -| uri-id | Id of the item-uri table entry that contains the apcontact url | int unsigned | YES | | NULL | | -| uuid | | varbinary(255) | YES | | NULL | | -| type | | varchar(20) | NO | | NULL | | -| following | | varbinary(383) | YES | | NULL | | -| followers | | varbinary(383) | YES | | NULL | | -| inbox | | varbinary(383) | NO | | NULL | | -| outbox | | varbinary(383) | YES | | NULL | | -| sharedinbox | | varbinary(383) | YES | | NULL | | -| featured | Address for the collection of featured posts | varbinary(383) | YES | | NULL | | -| featured-tags | Address for the collection of featured tags | varbinary(383) | YES | | NULL | | -| manually-approve | | boolean | YES | | NULL | | -| discoverable | Mastodon extension: true if profile is published in their directory | boolean | YES | | NULL | | -| suspended | Mastodon extension: true if profile is suspended | boolean | YES | | NULL | | -| nick | | varchar(255) | NO | | | | -| name | | varchar(255) | YES | | NULL | | -| about | | text | YES | | NULL | | -| xmpp | XMPP address | varchar(255) | YES | | NULL | | -| matrix | Matrix address | varchar(255) | YES | | NULL | | -| photo | | varbinary(383) | YES | | NULL | | -| header | Header picture | varbinary(383) | YES | | NULL | | -| addr | | varchar(255) | YES | | NULL | | -| alias | | varbinary(383) | YES | | NULL | | -| pubkey | | text | YES | | NULL | | -| subscribe | | varbinary(383) | YES | | NULL | | -| baseurl | baseurl of the ap contact | varbinary(383) | YES | | NULL | | -| gsid | Global Server ID | int unsigned | YES | | NULL | | -| generator | Name of the contact's system | varchar(255) | YES | | NULL | | -| following_count | Number of following contacts | int unsigned | YES | | 0 | | -| followers_count | Number of followers | int unsigned | YES | | 0 | | -| statuses_count | Number of posts | int unsigned | YES | | 0 | | -| updated | | datetime | NO | | 0001-01-01 00:00:00 | | +| Field | Description | Type | Null | Key | Default | Extra | +| ------------------ | ------------------------------------------------------------------- | -------------- | ---- | --- | ------------------- | ----- | +| url | URL of the contact | varbinary(383) | NO | PRI | NULL | | +| uri-id | Id of the item-uri table entry that contains the apcontact url | int unsigned | YES | | NULL | | +| uuid | | varbinary(255) | YES | | NULL | | +| type | | varchar(20) | NO | | NULL | | +| following | | varbinary(383) | YES | | NULL | | +| followers | | varbinary(383) | YES | | NULL | | +| inbox | | varbinary(383) | NO | | NULL | | +| outbox | | varbinary(383) | YES | | NULL | | +| sharedinbox | | varbinary(383) | YES | | NULL | | +| featured | Address for the collection of featured posts | varbinary(383) | YES | | NULL | | +| featured-tags | Address for the collection of featured tags | varbinary(383) | YES | | NULL | | +| manually-approve | | boolean | YES | | NULL | | +| discoverable | Mastodon extension: true if profile is published in their directory | boolean | YES | | NULL | | +| suspended | Mastodon extension: true if profile is suspended | boolean | YES | | NULL | | +| posting-restricted | lemmy:postingRestrictedToMods | boolean | YES | | NULL | | +| nick | | varchar(255) | NO | | | | +| name | | varchar(255) | YES | | NULL | | +| about | | text | YES | | NULL | | +| xmpp | XMPP address | varchar(255) | YES | | NULL | | +| matrix | Matrix address | varchar(255) | YES | | NULL | | +| photo | | varbinary(383) | YES | | NULL | | +| header | Header picture | varbinary(383) | YES | | NULL | | +| addr | | varchar(255) | YES | | NULL | | +| alias | | varbinary(383) | YES | | NULL | | +| pubkey | | text | YES | | NULL | | +| subscribe | | varbinary(383) | YES | | NULL | | +| baseurl | baseurl of the ap contact | varbinary(383) | YES | | NULL | | +| gsid | Global Server ID | int unsigned | YES | | NULL | | +| generator | Name of the contact's system | varchar(255) | YES | | NULL | | +| following_count | Number of following contacts | int unsigned | YES | | 0 | | +| followers_count | Number of followers | int unsigned | YES | | 0 | | +| statuses_count | Number of posts | int unsigned | YES | | 0 | | +| updated | | datetime | NO | | 0001-01-01 00:00:00 | | Indexes ------------ diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 714e229c4d..4a778db10d 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -295,6 +295,10 @@ class APContact return $fetched_contact; } + if (!empty($compacted['https://webfinger.net/#'])) { + $apcontact['addr'] = JsonLD::fetchElement($compacted, 'https://webfinger.net/#'); + } + if (empty($apcontact['addr']) && ($apcontact['type'] != 'Tombstone')) { try { $apcontact['addr'] = $apcontact['nick'] . '@' . (new Uri($apcontact['url']))->getAuthority(); @@ -313,7 +317,7 @@ class APContact } $apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers'); - + $apcontact['posting-restricted'] = (int)JsonLD::fetchElement($compacted, 'lemmy:postingRestrictedToMods'); $apcontact['suspended'] = (int)JsonLD::fetchElement($compacted, 'toot:suspended'); if (!empty($compacted['as:generator'])) { diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 2e1d4430f9..742798c144 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -993,6 +993,11 @@ class Processor } } + $author = Contact::selectFirstAccount(['ap-posting-restricted'], ['id' => $item['author-id']]); + if (!empty($author['ap-posting-restricted'])) { + $item['restrictions'] = $item['restrictions'] | Item::CANT_REPLY; + } + $item['location'] = $activity['location']; if (!empty($activity['latitude']) && !empty($activity['longitude'])) { diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 2b93a13d3b..18ff55e154 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -605,6 +605,8 @@ class Receiver * @param boolean $trust_source Do we trust the source? * @param boolean $push Message had been pushed to our system * @param array $signer The signer of the post + * @param string $http_signer + * @param int $completion * * @return bool * diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index 8b70933217..efdcc7ef76 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -176,6 +176,7 @@ class JsonLD 'fedibird' => (object)['@id' => 'http://fedibird.com/ns#', '@type' => '@id'], 'misskey' => (object)['@id' => 'https://misskey-hub.net/ns#', '@type' => '@id'], 'pixelfed' => (object)['@id' => 'http://pixelfed.org/ns#', '@type' => '@id'], + 'lemmy' => (object)['@id' => 'https://join-lemmy.org/ns#', '@type' => '@id'], ]; $orig_json = $json; diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 771c24d693..c1a98acf89 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -56,7 +56,7 @@ use Friendica\Database\DBA; // This file is required several times during the test in DbaDefinition which justifies this condition if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1571); + define('DB_UPDATE_VERSION', 1572); } return [ @@ -432,6 +432,7 @@ return [ "manually-approve" => ["type" => "boolean", "comment" => ""], "discoverable" => ["type" => "boolean", "comment" => "Mastodon extension: true if profile is published in their directory"], "suspended" => ["type" => "boolean", "comment" => "Mastodon extension: true if profile is suspended"], + "posting-restricted" => ["type" => "boolean", "comment" => "lemmy:postingRestrictedToMods"], "nick" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "name" => ["type" => "varchar(255)", "comment" => ""], "about" => ["type" => "text", "comment" => ""], diff --git a/static/dbview.config.php b/static/dbview.config.php index ce06004d96..5832e26b62 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -1621,6 +1621,7 @@ "ap-outbox" => ["apcontact", "outbox"], "ap-sharedinbox" => ["apcontact", "sharedinbox"], "ap-generator" => ["apcontact", "generator"], + "ap-posting-restricted" => ["apcontact", "posting-restricted"], "ap-following_count" => ["apcontact", "following_count"], "ap-followers_count" => ["apcontact", "followers_count"], "ap-statuses_count" => ["apcontact", "statuses_count"], @@ -1725,6 +1726,7 @@ "ap-outbox" => ["apcontact", "outbox"], "ap-sharedinbox" => ["apcontact", "sharedinbox"], "ap-generator" => ["apcontact", "generator"], + "ap-posting-restricted" => ["apcontact", "posting-restricted"], "ap-following_count" => ["apcontact", "following_count"], "ap-followers_count" => ["apcontact", "followers_count"], "ap-statuses_count" => ["apcontact", "statuses_count"],