Merge pull request #13368 from MrPetovan/bug/13367-post-plink

Replace reference to post plink by author base URL
This commit is contained in:
Michael Vogel 2023-08-26 00:03:45 +02:00 committed by GitHub
commit ddc3c0db03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 18 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2023.09-dev (Giant Rhubarb) -- Friendica 2023.09-dev (Giant Rhubarb)
-- DB_UPDATE_VERSION 1528 -- DB_UPDATE_VERSION 1529
-- ------------------------------------------ -- ------------------------------------------
@ -173,8 +173,8 @@ CREATE TABLE IF NOT EXISTS `contact` (
`archive` boolean NOT NULL DEFAULT '0' COMMENT '', `archive` boolean NOT NULL DEFAULT '0' COMMENT '',
`unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable', `unsearchable` boolean NOT NULL DEFAULT '0' COMMENT 'Contact prefers to not be searchable',
`sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content', `sensitive` boolean NOT NULL DEFAULT '0' COMMENT 'Contact posts sensitive content',
`baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact', `baseurl` varbinary(383) DEFAULT '' COMMENT 'baseurl of the contact from the gserver record, can be missing',
`gsid` int unsigned COMMENT 'Global Server ID', `gsid` int unsigned COMMENT 'Global Server ID, can be missing',
`bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '', `bd` date NOT NULL DEFAULT '0001-01-01' COMMENT '',
`reason` text COMMENT '', `reason` text COMMENT '',
`self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self', `self` boolean NOT NULL DEFAULT '0' COMMENT '1 if the contact is the user him/her self',
@ -2045,6 +2045,7 @@ CREATE VIEW `post-user-view` AS SELECT
`author`.`hidden` AS `author-hidden`, `author`.`hidden` AS `author-hidden`,
`author`.`updated` AS `author-updated`, `author`.`updated` AS `author-updated`,
`author`.`gsid` AS `author-gsid`, `author`.`gsid` AS `author-gsid`,
`author`.`baseurl` AS `author-baseurl`,
`post-user`.`owner-id` AS `owner-id`, `post-user`.`owner-id` AS `owner-id`,
`owner`.`uri-id` AS `owner-uri-id`, `owner`.`uri-id` AS `owner-uri-id`,
`owner`.`url` AS `owner-link`, `owner`.`url` AS `owner-link`,

View File

@ -51,8 +51,8 @@ Fields
| archive | | boolean | NO | | 0 | | | archive | | boolean | NO | | 0 | |
| unsearchable | Contact prefers to not be searchable | boolean | NO | | 0 | | | unsearchable | Contact prefers to not be searchable | boolean | NO | | 0 | |
| sensitive | Contact posts sensitive content | boolean | NO | | 0 | | | sensitive | Contact posts sensitive content | boolean | NO | | 0 | |
| baseurl | baseurl of the contact | varbinary(383) | YES | | | | | baseurl | baseurl of the contact from the gserver record, can be missing | varbinary(383) | YES | | | |
| gsid | Global Server ID | int unsigned | YES | | NULL | | | gsid | Global Server ID, can be missing | int unsigned | YES | | NULL | |
| bd | | date | NO | | 0001-01-01 | | | bd | | date | NO | | 0001-01-01 | |
| reason | | text | YES | | NULL | | | reason | | text | YES | | NULL | |
| self | 1 if the contact is the user him/her self | boolean | NO | | 0 | | | self | 1 if the contact is the user him/her self | boolean | NO | | 0 | |

View File

@ -34,15 +34,16 @@ use Friendica\Core\Protocol;
use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach; use Friendica\Model\Attach;
use Friendica\Model\Circle;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation; use Friendica\Model\Conversation;
use Friendica\Model\FileTag; use Friendica\Model\FileTag;
use Friendica\Model\Circle;
use Friendica\Model\Item as ItemModel; use Friendica\Model\Item as ItemModel;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\Tag;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Object\EMail\ItemCCEMail; use Friendica\Object\EMail\ItemCCEMail;
@ -50,11 +51,11 @@ use Friendica\Protocol\Activity;
use Friendica\Util\ACLFormatter; use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer; use Friendica\Util\Emailer;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Friendica\Util\Proxy; use Friendica\Util\Proxy;
use Friendica\Util\XML; use Friendica\Util\XML;
use GuzzleHttp\Psr7\Uri;
/** /**
* A content helper class for displaying items * A content helper class for displaying items
@ -408,8 +409,9 @@ class Item
$collapse_link = $item['self'] ? '' : $contact_url . '/collapse?t=' . $formSecurityToken; $collapse_link = $item['self'] ? '' : $contact_url . '/collapse?t=' . $formSecurityToken;
} }
if (!empty($item['author-gsid'])) { $authorBaseUri = new Uri($item['author-baseurl'] ?? '');
$ignoreserver_link = Network::isLocalLink($contact_url) ? '' : 'settings/server/' . $item['author-gsid'] . '/ignore'; if (!empty($item['author-gsid']) && $authorBaseUri->getHost() && !DI::baseUrl()->isLocalUrl($authorBaseUri)) {
$ignoreserver_link = 'settings/server/' . $item['author-gsid'] . '/ignore';
} }
if ($cid && !$item['self']) { if ($cid && !$item['self']) {

View File

@ -95,7 +95,7 @@ class Item
'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language', 'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object', 'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global', 'quote-uri', 'quote-uri-id', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention', 'global',
'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-addr', 'author-uri-id', 'author-id', 'author-link', 'author-alias', 'author-name', 'author-avatar', 'author-network', 'author-updated', 'author-gsid', 'author-baseurl', 'author-addr', 'author-uri-id',
'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated', 'owner-gsid', 'owner-id', 'owner-link', 'owner-alias', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type', 'owner-updated', 'owner-gsid',
'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', 'causer-gsid', 'causer-id', 'causer-link', 'causer-alias', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network', 'causer-gsid',
'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar', 'contact-id', 'contact-uid', 'contact-link', 'contact-name', 'contact-avatar',

View File

@ -31,17 +31,15 @@ use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Post as PostModel; use Friendica\Model\Post as PostModel;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Proxy;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use GuzzleHttp\Psr7\Uri;
use InvalidArgumentException; use InvalidArgumentException;
/** /**
@ -284,7 +282,8 @@ class Post
'label' => DI::l10n()->t('Report post'), 'label' => DI::l10n()->t('Report post'),
'href' => 'moderation/report/create?' . http_build_query(['cid' => $item['author-id'], 'uri-ids' => [$item['uri-id']]]), 'href' => 'moderation/report/create?' . http_build_query(['cid' => $item['author-id'], 'uri-ids' => [$item['uri-id']]]),
]; ];
if (!Network::isLocalLink($item['plink'])) { $authorBaseUri = new Uri($item['author-baseurl'] ?? '');
if ($authorBaseUri->getHost() && !DI::baseUrl()->isLocalUrl($authorBaseUri)) {
$ignoreServer = [ $ignoreServer = [
'label' => DI::l10n()->t("Ignore %s's server", $item['author-name']), 'label' => DI::l10n()->t("Ignore %s's server", $item['author-name']),
]; ];

View File

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition // This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1528); define('DB_UPDATE_VERSION', 1529);
} }
return [ return [
@ -230,8 +230,8 @@ return [
"archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "archive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"unsearchable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Contact prefers to not be searchable"], "unsearchable" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Contact prefers to not be searchable"],
"sensitive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Contact posts sensitive content"], "sensitive" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Contact posts sensitive content"],
"baseurl" => ["type" => "varbinary(383)", "default" => "", "comment" => "baseurl of the contact"], "baseurl" => ["type" => "varbinary(383)", "default" => "", "comment" => "baseurl of the contact from the gserver record, can be missing"],
"gsid" => ["type" => "int unsigned", "foreign" => ["gserver" => "id", "on delete" => "restrict"], "comment" => "Global Server ID"], "gsid" => ["type" => "int unsigned", "foreign" => ["gserver" => "id", "on delete" => "restrict"], "comment" => "Global Server ID, can be missing"],
"bd" => ["type" => "date", "not null" => "1", "default" => DBA::NULL_DATE, "comment" => ""], "bd" => ["type" => "date", "not null" => "1", "default" => DBA::NULL_DATE, "comment" => ""],
// User depending fields // User depending fields
"reason" => ["type" => "text", "comment" => ""], "reason" => ["type" => "text", "comment" => ""],

View File

@ -185,6 +185,7 @@
"author-hidden" => ["author", "hidden"], "author-hidden" => ["author", "hidden"],
"author-updated" => ["author", "updated"], "author-updated" => ["author", "updated"],
"author-gsid" => ["author", "gsid"], "author-gsid" => ["author", "gsid"],
"author-baseurl" => ["author", "baseurl"],
"owner-id" => ["post-user", "owner-id"], "owner-id" => ["post-user", "owner-id"],
"owner-uri-id" => ["owner", "uri-id"], "owner-uri-id" => ["owner", "uri-id"],
"owner-link" => ["owner", "url"], "owner-link" => ["owner", "url"],