Add constants for the Fetch Further Information field
This commit is contained in:
parent
3a98b958d3
commit
d0a2357fbd
6 changed files with 27 additions and 12 deletions
|
@ -1835,7 +1835,7 @@ CREATE TABLE IF NOT EXISTS `user-contact` (
|
||||||
`info` mediumtext COMMENT '',
|
`info` mediumtext COMMENT '',
|
||||||
`notify_new_posts` boolean COMMENT '',
|
`notify_new_posts` boolean COMMENT '',
|
||||||
`remote_self` boolean COMMENT '',
|
`remote_self` boolean COMMENT '',
|
||||||
`fetch_further_information` tinyint unsigned COMMENT '',
|
`fetch_further_information` tinyint unsigned COMMENT '0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both',
|
||||||
`ffi_keyword_denylist` text COMMENT '',
|
`ffi_keyword_denylist` text COMMENT '',
|
||||||
`subhub` boolean COMMENT '',
|
`subhub` boolean COMMENT '',
|
||||||
`hub-verify` varbinary(383) COMMENT '',
|
`hub-verify` varbinary(383) COMMENT '',
|
||||||
|
|
|
@ -47,6 +47,12 @@ use Friendica\Model\Contact;
|
||||||
*/
|
*/
|
||||||
class LocalRelationship extends \Friendica\BaseEntity
|
class LocalRelationship extends \Friendica\BaseEntity
|
||||||
{
|
{
|
||||||
|
// Fetch Further Information options, not a binary flag
|
||||||
|
const FFI_NONE = 0;
|
||||||
|
const FFI_INFORMATION = 1;
|
||||||
|
const FFI_KEYWORD = 3;
|
||||||
|
const FFI_BOTH = 2;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $userId;
|
protected $userId;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
|
@ -70,6 +76,7 @@ class LocalRelationship extends \Friendica\BaseEntity
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
protected $isRemoteSelf;
|
protected $isRemoteSelf;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
|
/** @var int One of FFI_* */
|
||||||
protected $fetchFurtherInformation;
|
protected $fetchFurtherInformation;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $ffiKeywordDenylist;
|
protected $ffiKeywordDenylist;
|
||||||
|
@ -84,7 +91,7 @@ class LocalRelationship extends \Friendica\BaseEntity
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $priority;
|
protected $priority;
|
||||||
|
|
||||||
public function __construct(int $userId, int $contactId, bool $blocked = false, bool $ignored = false, bool $collapsed = false, bool $hidden = false, bool $pending = false, int $rel = Contact::NOTHING, string $info = '', bool $notifyNewPosts = false, bool $isRemoteSelf = false, int $fetchFurtherInformation = 0, string $ffiKeywordDenylist = '', bool $subhub = false, string $hubVerify = '', string $protocol = Protocol::PHANTOM, ?int $rating = null, ?int $priority = null)
|
public function __construct(int $userId, int $contactId, bool $blocked = false, bool $ignored = false, bool $collapsed = false, bool $hidden = false, bool $pending = false, int $rel = Contact::NOTHING, string $info = '', bool $notifyNewPosts = false, bool $isRemoteSelf = false, int $fetchFurtherInformation = self::FFI_NONE, string $ffiKeywordDenylist = '', bool $subhub = false, string $hubVerify = '', string $protocol = Protocol::PHANTOM, ?int $rating = null, ?int $priority = null)
|
||||||
{
|
{
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->contactId = $contactId;
|
$this->contactId = $contactId;
|
||||||
|
|
|
@ -46,7 +46,7 @@ class LocalRelationship extends BaseFactory implements ICanCreateFromTableRow
|
||||||
$row['info'] ?? '',
|
$row['info'] ?? '',
|
||||||
$row['notify_new_posts'] ?? false,
|
$row['notify_new_posts'] ?? false,
|
||||||
$row['remote_self'] ?? false,
|
$row['remote_self'] ?? false,
|
||||||
$row['fetch_further_information'] ?? 0,
|
$row['fetch_further_information'] ?? Entity\LocalRelationship::FFI_NONE,
|
||||||
$row['ffi_keyword_denylist'] ?? '',
|
$row['ffi_keyword_denylist'] ?? '',
|
||||||
$row['subhub'] ?? false,
|
$row['subhub'] ?? false,
|
||||||
$row['hub-verify'] ?? '',
|
$row['hub-verify'] ?? '',
|
||||||
|
|
|
@ -283,10 +283,10 @@ class Profile extends BaseModule
|
||||||
$localRelationship->fetchFurtherInformation,
|
$localRelationship->fetchFurtherInformation,
|
||||||
$this->t('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.'),
|
$this->t('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.'),
|
||||||
[
|
[
|
||||||
'0' => $this->t('Disabled'),
|
Entity\LocalRelationship::FFI_NONE => $this->t('Disabled'),
|
||||||
'1' => $this->t('Fetch information'),
|
Entity\LocalRelationship::FFI_INFORMATION => $this->t('Fetch information'),
|
||||||
'3' => $this->t('Fetch keywords'),
|
Entity\LocalRelationship::FFI_KEYWORD => $this->t('Fetch keywords'),
|
||||||
'2' => $this->t('Fetch information and keywords')
|
Entity\LocalRelationship::FFI_BOTH => $this->t('Fetch information and keywords')
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use DOMXPath;
|
use DOMXPath;
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
|
||||||
use Friendica\Content\PageInfo;
|
use Friendica\Content\PageInfo;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
|
@ -566,8 +567,10 @@ class Feed
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fetch_further_information = $contact['fetch_further_information'] ?? LocalRelationship::FFI_NONE;
|
||||||
|
|
||||||
$preview = '';
|
$preview = '';
|
||||||
if (!empty($contact['fetch_further_information']) && ($contact['fetch_further_information'] < 3)) {
|
if (in_array($fetch_further_information, [LocalRelationship::FFI_INFORMATION, LocalRelationship::FFI_BOTH])) {
|
||||||
// Handle enclosures and treat them as preview picture
|
// Handle enclosures and treat them as preview picture
|
||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
if ($attachment['mimetype'] == 'image/jpeg') {
|
if ($attachment['mimetype'] == 'image/jpeg') {
|
||||||
|
@ -611,7 +614,12 @@ class Feed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = PageInfo::queryUrl($item['plink'], false, $preview, ($contact['fetch_further_information'] == 2), $contact['ffi_keyword_denylist'] ?? '');
|
$data = PageInfo::queryUrl(
|
||||||
|
$item['plink'],
|
||||||
|
false,
|
||||||
|
$fetch_further_information == LocalRelationship::FFI_BOTH,
|
||||||
|
$contact['ffi_keyword_denylist'] ?? ''
|
||||||
|
);
|
||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
// Take the data that was provided by the feed if the query is empty
|
// Take the data that was provided by the feed if the query is empty
|
||||||
|
@ -630,7 +638,7 @@ class Feed
|
||||||
// We always strip the title since it will be added in the page information
|
// We always strip the title since it will be added in the page information
|
||||||
$item['title'] = '';
|
$item['title'] = '';
|
||||||
$item['body'] = $item['body'] . "\n" . PageInfo::getFooterFromData($data, false);
|
$item['body'] = $item['body'] . "\n" . PageInfo::getFooterFromData($data, false);
|
||||||
$taglist = $contact['fetch_further_information'] == 2 ? PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '') : [];
|
$taglist = $fetch_further_information == LocalRelationship::FFI_BOTH ? PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '') : [];
|
||||||
$item['object-type'] = Activity\ObjectType::BOOKMARK;
|
$item['object-type'] = Activity\ObjectType::BOOKMARK;
|
||||||
$attachments = [];
|
$attachments = [];
|
||||||
|
|
||||||
|
@ -662,7 +670,7 @@ class Feed
|
||||||
$item['body'] = '[abstract]' . HTML::toBBCode($summary, $basepath) . "[/abstract]\n" . $item['body'];
|
$item['body'] = '[abstract]' . HTML::toBBCode($summary, $basepath) . "[/abstract]\n" . $item['body'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($contact['fetch_further_information']) && ($contact['fetch_further_information'] == 3)) {
|
if ($fetch_further_information == LocalRelationship::FFI_KEYWORD) {
|
||||||
if (empty($taglist)) {
|
if (empty($taglist)) {
|
||||||
$taglist = PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '');
|
$taglist = PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1827,7 +1827,7 @@ return [
|
||||||
"info" => ["type" => "mediumtext", "comment" => ""],
|
"info" => ["type" => "mediumtext", "comment" => ""],
|
||||||
"notify_new_posts" => ["type" => "boolean", "comment" => ""],
|
"notify_new_posts" => ["type" => "boolean", "comment" => ""],
|
||||||
"remote_self" => ["type" => "boolean", "comment" => ""],
|
"remote_self" => ["type" => "boolean", "comment" => ""],
|
||||||
"fetch_further_information" => ["type" => "tinyint unsigned", "comment" => ""],
|
"fetch_further_information" => ["type" => "tinyint unsigned", "comment" => "0 => None, 1 => Fetch information, 3 => Fetch keywords, 2 => Fetch both"],
|
||||||
"ffi_keyword_denylist" => ["type" => "text", "comment" => ""],
|
"ffi_keyword_denylist" => ["type" => "text", "comment" => ""],
|
||||||
"subhub" => ["type" => "boolean", "comment" => ""],
|
"subhub" => ["type" => "boolean", "comment" => ""],
|
||||||
"hub-verify" => ["type" => "varbinary(383)", "comment" => ""],
|
"hub-verify" => ["type" => "varbinary(383)", "comment" => ""],
|
||||||
|
|
Loading…
Reference in a new issue