`info` mediumtext COMMENT '',
`notify_new_posts` 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 '',
`subhub` boolean COMMENT '',
`hub-verify` varbinary(383) COMMENT '',
*/
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 */
protected $userId;
/** @var int */
/** @var bool */
protected $isRemoteSelf;
/** @var int */
+ /** @var int One of FFI_* */
protected $fetchFurtherInformation;
/** @var string */
protected $ffiKeywordDenylist;
/** @var int */
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->contactId = $contactId;
$row['info'] ?? '',
$row['notify_new_posts'] ?? false,
$row['remote_self'] ?? false,
- $row['fetch_further_information'] ?? 0,
+ $row['fetch_further_information'] ?? Entity\LocalRelationship::FFI_NONE,
$row['ffi_keyword_denylist'] ?? '',
$row['subhub'] ?? false,
$row['hub-verify'] ?? '',
$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.'),
[
- '0' => $this->t('Disabled'),
- '1' => $this->t('Fetch information'),
- '3' => $this->t('Fetch keywords'),
- '2' => $this->t('Fetch information and keywords')
+ Entity\LocalRelationship::FFI_NONE => $this->t('Disabled'),
+ Entity\LocalRelationship::FFI_INFORMATION => $this->t('Fetch information'),
+ Entity\LocalRelationship::FFI_KEYWORD => $this->t('Fetch keywords'),
+ Entity\LocalRelationship::FFI_BOTH => $this->t('Fetch information and keywords')
]
];
}
use DOMElement;
use DOMXPath;
use Friendica\App;
+use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
use Friendica\Content\PageInfo;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
continue;
}
+ $fetch_further_information = $contact['fetch_further_information'] ?? LocalRelationship::FFI_NONE;
+
$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
foreach ($attachments as $attachment) {
if ($attachment['mimetype'] == 'image/jpeg') {
}
}
- $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)) {
// Take the data that was provided by the feed if the query is empty
// We always strip the title since it will be added in the page information
$item['title'] = '';
$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;
$attachments = [];
$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)) {
$taglist = PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '');
}
"info" => ["type" => "mediumtext", "comment" => ""],
"notify_new_posts" => ["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" => ""],
"subhub" => ["type" => "boolean", "comment" => ""],
"hub-verify" => ["type" => "varbinary(383)", "comment" => ""],