]> git.mxchange.org Git - friendica.git/commitdiff
Issue 14377: Support for "postingRestrictedToMods" added
authorMichael <heluecht@pirati.ca>
Tue, 20 Aug 2024 05:58:24 +0000 (05:58 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 20 Aug 2024 05:58:24 +0000 (05:58 +0000)
database.sql
doc/database/db_apcontact.md
src/Model/APContact.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php
src/Util/JsonLD.php
static/dbstructure.config.php
static/dbview.config.php

index acb9a861decedbae793a66c5d733b6d2673e78e2..ac253c9e7ac4c432c64f55c7b566769cde11b2c2 100644 (file)
@@ -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`,
index 1632378ea8e594dcdf7b7e24d6f8a08f88065891..902d41ae6b15a9087d2d1b74ee671012e29d31d5 100644 (file)
@@ -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
 ------------
index 714e229c4d4fa30fa42a113132ad11c9bf705e2a..4a778db10dbc8c1cd3e90ab4f8c8bb74a101540d 100644 (file)
@@ -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'])) {
index 2e1d4430f9766005752edae5f95df14e45dff8ed..742798c14431df8f963438bfac41a89945a3e06d 100644 (file)
@@ -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'])) {
index 2b93a13d3ba6ae2bef856882429f5b3ae3eb1e01..18ff55e15497bc9ad4516d3cabef415b6532f1fc 100644 (file)
@@ -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
         *
index 8b709332173b1a9b21f807330c6ec605e6f2ed8d..efdcc7ef76838fcf7e62c8245689976aaf136dab 100644 (file)
@@ -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;
index 771c24d693ca6d775c6032b8fc9e9da6d640b73c..c1a98acf892cbd45d8e07e25c9bdc95ac2491420 100644 (file)
@@ -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" => ""],
index ce06004d965457e08dc57617dde40fbe258f5ff2..5832e26b62a8f8b44ce02743097a299f0aac3799 100644 (file)
                        "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"],
                        "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"],