mirror of
https://github.com/friendica/friendica
synced 2025-05-12 06:24:11 +02:00
Fix code style
This commit is contained in:
parent
d4697a17a3
commit
0e59dba914
102 changed files with 3038 additions and 2764 deletions
|
@ -47,28 +47,28 @@ use Friendica\Util\JsonLD;
|
|||
class ActivityPub
|
||||
{
|
||||
const PUBLIC_COLLECTION = 'https://www.w3.org/ns/activitystreams#Public';
|
||||
const CONTEXT = [
|
||||
const CONTEXT = [
|
||||
'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1',
|
||||
[
|
||||
'ostatus' => 'http://ostatus.org#',
|
||||
'vcard' => 'http://www.w3.org/2006/vcard/ns#',
|
||||
'dfrn' => 'http://purl.org/macgirvin/dfrn/1.0/',
|
||||
'ostatus' => 'http://ostatus.org#',
|
||||
'vcard' => 'http://www.w3.org/2006/vcard/ns#',
|
||||
'dfrn' => 'http://purl.org/macgirvin/dfrn/1.0/',
|
||||
'diaspora' => 'https://diasporafoundation.org/ns/',
|
||||
'litepub' => 'http://litepub.social/ns#',
|
||||
'toot' => 'http://joinmastodon.org/ns#',
|
||||
'litepub' => 'http://litepub.social/ns#',
|
||||
'toot' => 'http://joinmastodon.org/ns#',
|
||||
'featured' => [
|
||||
"@id" => "toot:featured",
|
||||
"@id" => "toot:featured",
|
||||
"@type" => "@id",
|
||||
],
|
||||
'schema' => 'http://schema.org#',
|
||||
'schema' => 'http://schema.org#',
|
||||
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
||||
'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag',
|
||||
'quoteUrl' => 'as:quoteUrl',
|
||||
'conversation' => 'ostatus:conversation',
|
||||
'directMessage' => 'litepub:directMessage',
|
||||
'discoverable' => 'toot:discoverable',
|
||||
'PropertyValue' => 'schema:PropertyValue',
|
||||
'value' => 'schema:value',
|
||||
'sensitive' => 'as:sensitive', 'Hashtag' => 'as:Hashtag',
|
||||
'quoteUrl' => 'as:quoteUrl',
|
||||
'conversation' => 'ostatus:conversation',
|
||||
'directMessage' => 'litepub:directMessage',
|
||||
'discoverable' => 'toot:discoverable',
|
||||
'PropertyValue' => 'schema:PropertyValue',
|
||||
'value' => 'schema:value',
|
||||
]
|
||||
];
|
||||
const ACCOUNT_TYPES = ['Person', 'Organization', 'Service', 'Group', 'Application', 'Tombstone'];
|
||||
|
@ -142,35 +142,35 @@ class ActivityPub
|
|||
return [];
|
||||
}
|
||||
|
||||
$profile = ['network' => Protocol::ACTIVITYPUB];
|
||||
$profile['nick'] = $apcontact['nick'];
|
||||
$profile['name'] = $apcontact['name'];
|
||||
$profile['guid'] = $apcontact['uuid'];
|
||||
$profile['url'] = $apcontact['url'];
|
||||
$profile['addr'] = $apcontact['addr'];
|
||||
$profile['alias'] = $apcontact['alias'];
|
||||
$profile['following'] = $apcontact['following'];
|
||||
$profile['followers'] = $apcontact['followers'];
|
||||
$profile['inbox'] = $apcontact['inbox'];
|
||||
$profile['outbox'] = $apcontact['outbox'];
|
||||
$profile['sharedinbox'] = $apcontact['sharedinbox'];
|
||||
$profile['photo'] = $apcontact['photo'];
|
||||
$profile['header'] = $apcontact['header'];
|
||||
$profile = ['network' => Protocol::ACTIVITYPUB];
|
||||
$profile['nick'] = $apcontact['nick'];
|
||||
$profile['name'] = $apcontact['name'];
|
||||
$profile['guid'] = $apcontact['uuid'];
|
||||
$profile['url'] = $apcontact['url'];
|
||||
$profile['addr'] = $apcontact['addr'];
|
||||
$profile['alias'] = $apcontact['alias'];
|
||||
$profile['following'] = $apcontact['following'];
|
||||
$profile['followers'] = $apcontact['followers'];
|
||||
$profile['inbox'] = $apcontact['inbox'];
|
||||
$profile['outbox'] = $apcontact['outbox'];
|
||||
$profile['sharedinbox'] = $apcontact['sharedinbox'];
|
||||
$profile['photo'] = $apcontact['photo'];
|
||||
$profile['header'] = $apcontact['header'];
|
||||
$profile['account-type'] = self::getAccountType($apcontact);
|
||||
$profile['community'] = ($profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY);
|
||||
$profile['community'] = ($profile['account-type'] == User::ACCOUNT_TYPE_COMMUNITY);
|
||||
// $profile['keywords']
|
||||
// $profile['location']
|
||||
$profile['about'] = $apcontact['about'];
|
||||
$profile['xmpp'] = $apcontact['xmpp'];
|
||||
$profile['matrix'] = $apcontact['matrix'];
|
||||
$profile['batch'] = $apcontact['sharedinbox'];
|
||||
$profile['notify'] = $apcontact['inbox'];
|
||||
$profile['poll'] = $apcontact['outbox'];
|
||||
$profile['pubkey'] = $apcontact['pubkey'];
|
||||
$profile['subscribe'] = $apcontact['subscribe'];
|
||||
$profile['about'] = $apcontact['about'];
|
||||
$profile['xmpp'] = $apcontact['xmpp'];
|
||||
$profile['matrix'] = $apcontact['matrix'];
|
||||
$profile['batch'] = $apcontact['sharedinbox'];
|
||||
$profile['notify'] = $apcontact['inbox'];
|
||||
$profile['poll'] = $apcontact['outbox'];
|
||||
$profile['pubkey'] = $apcontact['pubkey'];
|
||||
$profile['subscribe'] = $apcontact['subscribe'];
|
||||
$profile['manually-approve'] = $apcontact['manually-approve'];
|
||||
$profile['baseurl'] = $apcontact['baseurl'];
|
||||
$profile['gsid'] = $apcontact['gsid'];
|
||||
$profile['baseurl'] = $apcontact['baseurl'];
|
||||
$profile['gsid'] = $apcontact['gsid'];
|
||||
|
||||
if (!is_null($apcontact['discoverable'])) {
|
||||
$profile['hide'] = !$apcontact['discoverable'];
|
||||
|
@ -307,7 +307,7 @@ class ActivityPub
|
|||
$limited = DI::config()->get('system', 'limited_servers');
|
||||
if (!empty($limited)) {
|
||||
$servers = explode(',', str_replace(' ', '', $limited));
|
||||
$host = parse_url($apcontact['baseurl'], PHP_URL_HOST);
|
||||
$host = parse_url($apcontact['baseurl'], PHP_URL_HOST);
|
||||
if (!empty($host) && in_array($host, $servers)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ class ClientToServer
|
|||
$item['uid'] = $uid;
|
||||
$item['verb'] = Activity::POST;
|
||||
$item['contact-id'] = $owner['id'];
|
||||
$item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid);
|
||||
$item['author-id'] = $item['owner-id'] = Contact::getPublicIdByUserId($uid);
|
||||
$item['title'] = $object_data['name'];
|
||||
$item['body'] = Markdown::toBBCode($object_data['content'] ?? '');
|
||||
$item['app'] = $application['name'] ?? 'API';
|
||||
|
@ -322,8 +322,10 @@ class ClientToServer
|
|||
if (!empty($requester_id)) {
|
||||
$permissionSets = DI::permissionSet()->selectByContactId($requester_id, $owner['uid']);
|
||||
if (count($permissionSets) > 0) {
|
||||
$condition = ['psid' => array_merge($permissionSets->column('id'),
|
||||
[DI::permissionSet()->selectPublicForUser($owner['uid'])])];
|
||||
$condition = ['psid' => array_merge(
|
||||
$permissionSets->column('id'),
|
||||
[DI::permissionSet()->selectPublicForUser($owner['uid'])]
|
||||
)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class Delivery
|
|||
} else {
|
||||
$data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
|
||||
if (!empty($data)) {
|
||||
$timestamp = microtime(true);
|
||||
$timestamp = microtime(true);
|
||||
try {
|
||||
$response = HTTPSignature::post($data, $inbox, $owner);
|
||||
$success = $response->isSuccess();
|
||||
|
@ -150,7 +150,7 @@ class Delivery
|
|||
|
||||
// Resubscribe to relay server upon client error
|
||||
if (!$serverfail && ($response->getReturnCode() >= 400) && ($response->getReturnCode() <= 499)) {
|
||||
$actor = self:: fetchActorForRelayInbox($inbox);
|
||||
$actor = self::fetchActorForRelayInbox($inbox);
|
||||
if (!empty($actor)) {
|
||||
$drop = !ActivityPub\Transmitter::sendRelayFollow($actor);
|
||||
DI::logger()->notice('Resubscribed to relay', ['url' => $actor, 'success' => !$drop]);
|
||||
|
|
|
@ -93,7 +93,7 @@ class Processor
|
|||
private static function processLanguages(array $languages): string
|
||||
{
|
||||
$codes = array_keys($languages);
|
||||
$lang = [];
|
||||
$lang = [];
|
||||
foreach ($codes as $code) {
|
||||
$lang[$code] = 1;
|
||||
}
|
||||
|
@ -145,15 +145,15 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
$data = ['uri-id' => $uriid];
|
||||
$data['type'] = Post\Media::UNKNOWN;
|
||||
$data['url'] = $attachment['url'];
|
||||
$data['mimetype'] = $attachment['mediaType'] ?? null;
|
||||
$data['height'] = $attachment['height'] ?? null;
|
||||
$data['width'] = $attachment['width'] ?? null;
|
||||
$data['size'] = $attachment['size'] ?? null;
|
||||
$data['preview'] = $attachment['image'] ?? null;
|
||||
$data['description'] = $attachment['name'] ?? null;
|
||||
$data = ['uri-id' => $uriid];
|
||||
$data['type'] = Post\Media::UNKNOWN;
|
||||
$data['url'] = $attachment['url'];
|
||||
$data['mimetype'] = $attachment['mediaType'] ?? null;
|
||||
$data['height'] = $attachment['height'] ?? null;
|
||||
$data['width'] = $attachment['width'] ?? null;
|
||||
$data['size'] = $attachment['size'] ?? null;
|
||||
$data['preview'] = $attachment['image'] ?? null;
|
||||
$data['description'] = $attachment['name'] ?? null;
|
||||
|
||||
Post\Media::insert($data);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class Processor
|
|||
}
|
||||
|
||||
$item['changed'] = DateTimeFormat::utcNow();
|
||||
$item['edited'] = DateTimeFormat::utc($activity['updated']);
|
||||
$item['edited'] = DateTimeFormat::utc($activity['updated']);
|
||||
|
||||
Post\Media::deleteByURIId($item['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE, Post\Media::HTML]);
|
||||
$item = self::processContent($activity, $item);
|
||||
|
@ -265,11 +265,11 @@ class Processor
|
|||
{
|
||||
$event = DBA::selectFirst('event', [], ['id' => $event_id]);
|
||||
|
||||
$event['edited'] = DateTimeFormat::utc($activity['updated']);
|
||||
$event['summary'] = HTML::toBBCode($activity['name']);
|
||||
$event['desc'] = HTML::toBBCode($activity['content']);
|
||||
$event['edited'] = DateTimeFormat::utc($activity['updated']);
|
||||
$event['summary'] = HTML::toBBCode($activity['name']);
|
||||
$event['desc'] = HTML::toBBCode($activity['content']);
|
||||
if (!empty($activity['start-time'])) {
|
||||
$event['start'] = DateTimeFormat::utc($activity['start-time']);
|
||||
$event['start'] = DateTimeFormat::utc($activity['start-time']);
|
||||
}
|
||||
if (!empty($activity['end-time'])) {
|
||||
$event['finish'] = DateTimeFormat::utc($activity['end-time']);
|
||||
|
@ -294,15 +294,15 @@ class Processor
|
|||
*/
|
||||
public static function createItem(array $activity, bool $fetch_parents): array
|
||||
{
|
||||
$item = [];
|
||||
$item['verb'] = Activity::POST;
|
||||
$item = [];
|
||||
$item['verb'] = Activity::POST;
|
||||
$item['thr-parent'] = $activity['reply-to-id'];
|
||||
|
||||
if ($activity['reply-to-id'] == $activity['id']) {
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
$item['gravity'] = Item::GRAVITY_PARENT;
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
} else {
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$item['gravity'] = Item::GRAVITY_COMMENT;
|
||||
$item['object-type'] = Activity\ObjectType::COMMENT;
|
||||
}
|
||||
|
||||
|
@ -318,14 +318,14 @@ class Processor
|
|||
$conversation = Post::selectFirstThread(['uri'], ['context' => $item['context']]);
|
||||
if (!empty($conversation)) {
|
||||
DI::logger()->debug('Got context', ['context' => $item['context'], 'parent' => $conversation]);
|
||||
$item['parent-uri'] = $conversation['uri'];
|
||||
$item['parent-uri'] = $conversation['uri'];
|
||||
$item['parent-uri-id'] = ItemURI::getIdByURI($item['parent-uri']);
|
||||
}
|
||||
} elseif (!empty($item['conversation'])) {
|
||||
$conversation = Post::selectFirstThread(['uri'], ['conversation' => $item['conversation']]);
|
||||
if (!empty($conversation)) {
|
||||
DI::logger()->debug('Got conversation', ['conversation' => $item['conversation'], 'parent' => $conversation]);
|
||||
$item['parent-uri'] = $conversation['uri'];
|
||||
$item['parent-uri'] = $conversation['uri'];
|
||||
$item['parent-uri-id'] = ItemURI::getIdByURI($item['parent-uri']);
|
||||
}
|
||||
} else {
|
||||
|
@ -360,11 +360,11 @@ class Processor
|
|||
return [];
|
||||
}
|
||||
|
||||
$item['network'] = Protocol::ACTIVITYPUB;
|
||||
$item['network'] = Protocol::ACTIVITYPUB;
|
||||
$item['author-link'] = $activity['author'];
|
||||
$item['author-id'] = Contact::getIdForURL($activity['author']);
|
||||
$item['owner-link'] = $activity['actor'];
|
||||
$item['owner-id'] = Contact::getIdForURL($activity['actor']);
|
||||
$item['author-id'] = Contact::getIdForURL($activity['author']);
|
||||
$item['owner-link'] = $activity['actor'];
|
||||
$item['owner-id'] = Contact::getIdForURL($activity['actor']);
|
||||
|
||||
if (in_array(0, $activity['receiver']) && !empty($activity['unlisted'])) {
|
||||
$item['private'] = Item::UNLISTED;
|
||||
|
@ -412,7 +412,7 @@ class Processor
|
|||
|
||||
if (!empty($activity['thread-completion'])) {
|
||||
if ($activity['thread-completion'] != $item['owner-id']) {
|
||||
$actor = Contact::getById($activity['thread-completion'], ['url']);
|
||||
$actor = Contact::getById($activity['thread-completion'], ['url']);
|
||||
$item['causer-link'] = $actor['url'];
|
||||
$item['causer-id'] = $activity['thread-completion'];
|
||||
DI::logger()->info('Use inherited actor as causer.', ['id' => $item['owner-id'], 'activity' => $activity['thread-completion'], 'owner' => $item['owner-link'], 'actor' => $actor['url']]);
|
||||
|
@ -461,7 +461,7 @@ class Processor
|
|||
$item['causer-id'] = Contact::getIdForURL($item['causer-link']);
|
||||
}
|
||||
|
||||
$item['uri'] = $activity['id'];
|
||||
$item['uri'] = $activity['id'];
|
||||
$item['sensitive'] = $activity['sensitive'];
|
||||
|
||||
if (empty($activity['published']) || empty($activity['updated'])) {
|
||||
|
@ -469,9 +469,9 @@ class Processor
|
|||
}
|
||||
|
||||
$item['created'] = DateTimeFormat::utc($activity['published'] ?? 'now');
|
||||
$item['edited'] = DateTimeFormat::utc($activity['updated'] ?? 'now');
|
||||
$guid = $activity['sc:identifier'] ?: self::getGUIDByURL($item['uri']);
|
||||
$item['guid'] = $activity['diaspora:guid'] ?: $guid;
|
||||
$item['edited'] = DateTimeFormat::utc($activity['updated'] ?? 'now');
|
||||
$guid = $activity['sc:identifier'] ?: self::getGUIDByURL($item['uri']);
|
||||
$item['guid'] = $activity['diaspora:guid'] ?: $guid;
|
||||
|
||||
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||
if (empty($item['uri-id'])) {
|
||||
|
@ -525,7 +525,7 @@ class Processor
|
|||
$replies[] = $item['parent-uri'];
|
||||
}
|
||||
$condition = DBA::mergeConditions(['uri' => $replies], ["`replies-id` IS NOT NULL"]);
|
||||
$posts = Post::select(['replies', 'replies-id'], $condition);
|
||||
$posts = Post::select(['replies', 'replies-id'], $condition);
|
||||
while ($post = Post::fetch($posts)) {
|
||||
$cachekey = 'Processor-CreateItem-Replies-' . $post['replies-id'];
|
||||
if (!DI::cache()->get($cachekey)) {
|
||||
|
@ -614,7 +614,7 @@ class Processor
|
|||
DI::logger()->notice('Fetching is done by worker.', ['parent' => $activity['reply-to-id'], 'recursion-depth' => $recursion_depth]);
|
||||
Fetch::add($activity['reply-to-id']);
|
||||
$activity['recursion-depth'] = 0;
|
||||
$wid = Worker::add(Worker::PRIORITY_HIGH, 'FetchMissingActivity', $activity['reply-to-id'], $activity, '', Receiver::COMPLETION_ASYNC);
|
||||
$wid = Worker::add(Worker::PRIORITY_HIGH, 'FetchMissingActivity', $activity['reply-to-id'], $activity, '', Receiver::COMPLETION_ASYNC);
|
||||
Fetch::setWorkerId($activity['reply-to-id'], $wid);
|
||||
} else {
|
||||
DI::logger()->debug('Activity will already be fetched via a worker.', ['url' => $activity['reply-to-id']]);
|
||||
|
@ -676,7 +676,7 @@ class Processor
|
|||
{
|
||||
$owner = Contact::getIdForURL($activity['actor']);
|
||||
|
||||
DI::logger()->info('Deleting item', ['object' => $activity['object_id'], 'owner' => $owner]);
|
||||
DI::logger()->info('Deleting item', ['object' => $activity['object_id'], 'owner' => $owner]);
|
||||
Item::markForDeletion(['uri' => $activity['object_id'], 'owner-id' => $owner]);
|
||||
Queue::remove($activity);
|
||||
}
|
||||
|
@ -722,15 +722,15 @@ class Processor
|
|||
public static function createActivity(array $activity, string $verb)
|
||||
{
|
||||
$activity['reply-to-id'] = $activity['object_id'];
|
||||
$item = self::createItem($activity, false);
|
||||
$item = self::createItem($activity, false);
|
||||
if (empty($item)) {
|
||||
DI::logger()->debug('Activity was not prepared', ['id' => $activity['object_id']]);
|
||||
return;
|
||||
}
|
||||
|
||||
$item['verb'] = $verb;
|
||||
$item['verb'] = $verb;
|
||||
$item['thr-parent'] = $activity['object_id'];
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$item['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
unset($item['post-type']);
|
||||
$item['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
||||
|
@ -830,10 +830,10 @@ class Processor
|
|||
*/
|
||||
public static function createEvent(array $activity, array $item): int
|
||||
{
|
||||
$event['summary'] = HTML::toBBCode($activity['name'] ?: $activity['summary']);
|
||||
$event['desc'] = HTML::toBBCode($activity['content'] ?? '');
|
||||
$event['summary'] = HTML::toBBCode($activity['name'] ?: $activity['summary']);
|
||||
$event['desc'] = HTML::toBBCode($activity['content'] ?? '');
|
||||
if (!empty($activity['start-time'])) {
|
||||
$event['start'] = DateTimeFormat::utc($activity['start-time']);
|
||||
$event['start'] = DateTimeFormat::utc($activity['start-time']);
|
||||
}
|
||||
if (!empty($activity['end-time'])) {
|
||||
$event['finish'] = DateTimeFormat::utc($activity['end-time']);
|
||||
|
@ -876,17 +876,17 @@ class Processor
|
|||
{
|
||||
if (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/markdown')) {
|
||||
$item['title'] = strip_tags($activity['name'] ?? '');
|
||||
$content = Markdown::toBBCode($activity['content'] ?? '');
|
||||
$content = Markdown::toBBCode($activity['content'] ?? '');
|
||||
} elseif (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/bbcode')) {
|
||||
$item['title'] = $activity['name'] ?? '';
|
||||
$content = $activity['content'] ?? '';
|
||||
$item['title'] = $activity['name'] ?? '';
|
||||
$content = $activity['content'] ?? '';
|
||||
} else {
|
||||
// By default assume "text/html"
|
||||
$item['title'] = HTML::toBBCode($activity['name'] ?? '');
|
||||
$content = HTML::toBBCode($activity['content'] ?? '');
|
||||
$content = HTML::toBBCode($activity['content'] ?? '');
|
||||
}
|
||||
|
||||
$item['title'] = trim(BBCode::toPlaintext($item['title']));
|
||||
$item['title'] = trim(BBCode::toPlaintext($item['title']));
|
||||
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? '');
|
||||
|
||||
if (!empty($activity['languages'])) {
|
||||
|
@ -904,7 +904,7 @@ class Processor
|
|||
if (!empty($activity['quote-url'])) {
|
||||
$id = Item::fetchByLink($activity['quote-url'], 0, ActivityPub\Receiver::COMPLETION_ASYNC);
|
||||
if ($id) {
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
$shared_item = Post::selectFirst(['uri-id'], ['id' => $id]);
|
||||
$item['quote-uri-id'] = $shared_item['uri-id'];
|
||||
DI::logger()->debug('Quote is found', ['guid' => $item['guid'], 'uri-id' => $item['uri-id'], 'quote' => $activity['quote-url'], 'quote-uri-id' => $item['quote-uri-id']]);
|
||||
} elseif ($uri_id = ItemURI::getIdByURI($activity['quote-url'], false)) {
|
||||
|
@ -919,7 +919,7 @@ class Processor
|
|||
}
|
||||
|
||||
if (!empty($activity['source'])) {
|
||||
$item['body'] = $activity['source'];
|
||||
$item['body'] = $activity['source'];
|
||||
$item['raw-body'] = $content;
|
||||
|
||||
$quote_uri_id = Item::getQuoteUriId($item['body']);
|
||||
|
@ -1093,7 +1093,7 @@ class Processor
|
|||
return;
|
||||
}
|
||||
|
||||
$stored = false;
|
||||
$stored = false;
|
||||
$success = false;
|
||||
ksort($activity['receiver']);
|
||||
|
||||
|
@ -1194,14 +1194,16 @@ class Processor
|
|||
|
||||
if ((DI::pConfig()->get($receiver, 'system', 'accept_only_sharer') != Item::COMPLETION_LIKE)
|
||||
&& in_array($activity['thread-children-type'] ?? '', Receiver::ACTIVITY_TYPES)) {
|
||||
DI::logger()->info('Top level post from thread completion from a non sharer had been initiated via an activity, ignoring',
|
||||
['type' => $activity['thread-children-type'], 'user' => $item['uid'], 'causer' => $item['causer-link'], 'author' => $activity['author'], 'url' => $item['uri']]);
|
||||
DI::logger()->info(
|
||||
'Top level post from thread completion from a non sharer had been initiated via an activity, ignoring',
|
||||
['type' => $activity['thread-children-type'], 'user' => $item['uid'], 'causer' => $item['causer-link'], 'author' => $activity['author'], 'url' => $item['uri']]
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$isGroup = false;
|
||||
$user = User::getById($receiver, ['account-type']);
|
||||
$user = User::getById($receiver, ['account-type']);
|
||||
if (!empty($user['account-type'])) {
|
||||
$isGroup = ($user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY);
|
||||
}
|
||||
|
@ -1310,7 +1312,7 @@ class Processor
|
|||
if (Post::exists(['uri-id' => $item['parent-uri-id'], 'uid' => $receiver])) {
|
||||
$has_parents = true;
|
||||
} elseif ($add_parent && Post::exists(['uri-id' => $item['parent-uri-id'], 'uid' => 0])) {
|
||||
$stored = Item::storeForUserByUriId($item['parent-uri-id'], $receiver, $fields);
|
||||
$stored = Item::storeForUserByUriId($item['parent-uri-id'], $receiver, $fields);
|
||||
$has_parents = (bool)$stored;
|
||||
if ($stored) {
|
||||
DI::logger()->notice('Inserted missing parent post', ['stored' => $stored, 'uid' => $receiver, 'parent' => $item['parent-uri']]);
|
||||
|
@ -1329,7 +1331,7 @@ class Processor
|
|||
if (Post::exists(['uri-id' => $item['thr-parent-id'], 'uid' => $receiver])) {
|
||||
$has_parents = true;
|
||||
} elseif (($has_parents || $add_parent) && Post::exists(['uri-id' => $item['thr-parent-id'], 'uid' => 0])) {
|
||||
$stored = Item::storeForUserByUriId($item['thr-parent-id'], $receiver, $fields);
|
||||
$stored = Item::storeForUserByUriId($item['thr-parent-id'], $receiver, $fields);
|
||||
$has_parents = $has_parents || (bool)$stored;
|
||||
if ($stored) {
|
||||
DI::logger()->notice('Inserted missing thread parent post', ['stored' => $stored, 'uid' => $receiver, 'thread-parent' => $item['thr-parent']]);
|
||||
|
@ -1462,23 +1464,23 @@ class Processor
|
|||
|
||||
DI::logger()->info('Direct Message', $item);
|
||||
|
||||
$msg = [];
|
||||
$msg = [];
|
||||
$msg['uid'] = $item['uid'];
|
||||
|
||||
$msg['contact-id'] = $item['contact-id'];
|
||||
|
||||
$contact = Contact::getById($item['contact-id'], ['name', 'url', 'photo']);
|
||||
$msg['from-name'] = $contact['name'];
|
||||
$msg['from-url'] = $contact['url'];
|
||||
$contact = Contact::getById($item['contact-id'], ['name', 'url', 'photo']);
|
||||
$msg['from-name'] = $contact['name'];
|
||||
$msg['from-url'] = $contact['url'];
|
||||
$msg['from-photo'] = $contact['photo'];
|
||||
|
||||
$msg['uri'] = $item['uri'];
|
||||
$msg['uri'] = $item['uri'];
|
||||
$msg['created'] = $item['created'];
|
||||
|
||||
$parent = DBA::selectFirst('mail', ['parent-uri', 'title'], ['uri' => $item['thr-parent']]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$msg['parent-uri'] = $parent['parent-uri'];
|
||||
$msg['title'] = $parent['title'];
|
||||
$msg['title'] = $parent['title'];
|
||||
} else {
|
||||
$msg['parent-uri'] = $item['thr-parent'];
|
||||
|
||||
|
@ -1587,7 +1589,7 @@ class Processor
|
|||
public static function fetchCachedActivity(string $url, int $uid): array
|
||||
{
|
||||
$cachekey = self::CACHEKEY_FETCH_ACTIVITY . $uid . ':' . hash('sha256', $url);
|
||||
$object = DI::cache()->get($cachekey);
|
||||
$object = DI::cache()->get($cachekey);
|
||||
|
||||
if (!is_null($object)) {
|
||||
if (!empty($object)) {
|
||||
|
@ -1709,7 +1711,7 @@ class Processor
|
|||
$signer[] = $object_actor;
|
||||
|
||||
if (!empty($child['author'])) {
|
||||
$actor = $child['author'];
|
||||
$actor = $child['author'];
|
||||
$signer[] = $actor;
|
||||
} else {
|
||||
$actor = $object_actor;
|
||||
|
@ -1740,7 +1742,7 @@ class Processor
|
|||
}
|
||||
|
||||
$ldactivity['recursion-depth'] = !empty($child['recursion-depth']) ? $child['recursion-depth'] + 1 : 0;
|
||||
$ldactivity['children'] = $child['children'] ?? [];
|
||||
$ldactivity['children'] = $child['children'] ?? [];
|
||||
$ldactivity['callstack'] = $child['callstack'] ?? [];
|
||||
// This check is mostly superfluous, since there are similar checks before. This covers the case, when the fetched id doesn't match the url
|
||||
if (in_array($activity['id'], $ldactivity['children'])) {
|
||||
|
@ -1801,7 +1803,7 @@ class Processor
|
|||
}
|
||||
}
|
||||
|
||||
$callstack = array_slice(array_column(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), 'function'), 1);
|
||||
$callstack = array_slice(array_column(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), 'function'), 1);
|
||||
$system_count = 0;
|
||||
foreach ($callstack as $function) {
|
||||
if ($function == __FUNCTION__) {
|
||||
|
@ -1829,7 +1831,7 @@ class Processor
|
|||
|
||||
if (is_array($reply)) {
|
||||
$ldobject = JsonLD::compact($reply);
|
||||
$id = JsonLD::fetchElement($ldobject, '@id');
|
||||
$id = JsonLD::fetchElement($ldobject, '@id');
|
||||
if (Processor::alreadyKnown($id, $child['id'] ?? '')) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1915,7 +1917,7 @@ class Processor
|
|||
$actor = JsonLD::fetchElement($ldobject, 'as:actor', '@id');
|
||||
$attributed_to = JsonLD::fetchElement($ldobject, 'as:attributedTo', '@id');
|
||||
|
||||
$id_host = parse_url($id, PHP_URL_HOST);
|
||||
$id_host = parse_url($id, PHP_URL_HOST);
|
||||
|
||||
if (!empty($actor) && !in_array($type, Receiver::CONTENT_TYPES) && !empty($object_id)) {
|
||||
$actor_host = parse_url($actor, PHP_URL_HOST);
|
||||
|
@ -1951,17 +1953,17 @@ class Processor
|
|||
$published = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
||||
$activity = [];
|
||||
$activity = [];
|
||||
$activity['@context'] = $object['@context'] ?? ActivityPub::CONTEXT;
|
||||
unset($object['@context']);
|
||||
$activity['id'] = $object['id'];
|
||||
$activity['to'] = $object['to'] ?? [];
|
||||
$activity['cc'] = $object['cc'] ?? [];
|
||||
$activity['audience'] = $object['audience'] ?? [];
|
||||
$activity['actor'] = $actor;
|
||||
$activity['object'] = $object;
|
||||
$activity['id'] = $object['id'];
|
||||
$activity['to'] = $object['to'] ?? [];
|
||||
$activity['cc'] = $object['cc'] ?? [];
|
||||
$activity['audience'] = $object['audience'] ?? [];
|
||||
$activity['actor'] = $actor;
|
||||
$activity['object'] = $object;
|
||||
$activity['published'] = $published;
|
||||
$activity['type'] = 'Create';
|
||||
$activity['type'] = 'Create';
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
@ -1983,16 +1985,16 @@ class Processor
|
|||
$id = JsonLD::fetchElement($activity, 'as:object', '@id');
|
||||
|
||||
$replyto = JsonLD::fetchElement($activity['as:object'], 'as:inReplyTo', '@id');
|
||||
$uriid = ItemURI::getIdByURI($replyto ?? '');
|
||||
$uriid = ItemURI::getIdByURI($replyto ?? '');
|
||||
if (Post::exists(['uri-id' => $uriid])) {
|
||||
DI::logger()->info('Post is a reply to an existing post - accepted', ['id' => $id, 'uri-id' => $uriid, 'replyto' => $replyto]);
|
||||
return true;
|
||||
}
|
||||
|
||||
$attributed_to = JsonLD::fetchElement($activity['as:object'], 'as:attributedTo', '@id');
|
||||
$authorid = Contact::getIdForURL($attributed_to);
|
||||
$authorid = Contact::getIdForURL($attributed_to);
|
||||
|
||||
$content = JsonLD::fetchElement($activity['as:object'], 'as:name', '@value') ?? '';
|
||||
$content = JsonLD::fetchElement($activity['as:object'], 'as:name', '@value') ?? '';
|
||||
$content .= ' ' . JsonLD::fetchElement($activity['as:object'], 'as:summary', '@value') ?? '';
|
||||
$content .= ' ' . HTML::toBBCode(JsonLD::fetchElement($activity['as:object'], 'as:content', '@value') ?? '');
|
||||
|
||||
|
@ -2007,7 +2009,7 @@ class Processor
|
|||
}
|
||||
|
||||
$messageTags = [];
|
||||
$tags = Receiver::processTags(JsonLD::fetchElementArray($activity['as:object'], 'as:tag') ?? []);
|
||||
$tags = Receiver::processTags(JsonLD::fetchElementArray($activity['as:object'], 'as:tag') ?? []);
|
||||
if (!empty($tags)) {
|
||||
foreach ($tags as $tag) {
|
||||
if (($tag['type'] != 'Hashtag') && !strpos($tag['type'], ':Hashtag') || empty($tag['name'])) {
|
||||
|
@ -2047,13 +2049,13 @@ class Processor
|
|||
*/
|
||||
public static function getPostLanguages(array $activity): array
|
||||
{
|
||||
$content = JsonLD::fetchElement($activity, 'as:content') ?? '';
|
||||
$content = JsonLD::fetchElement($activity, 'as:content') ?? '';
|
||||
$languages = JsonLD::fetchElementArray($activity, 'as:content', '@language') ?? [];
|
||||
if (empty($languages)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$iso639 = new \Matriphe\ISO639\ISO639;
|
||||
$iso639 = new \Matriphe\ISO639\ISO639();
|
||||
|
||||
$result = [];
|
||||
foreach ($languages as $language) {
|
||||
|
@ -2097,7 +2099,7 @@ class Processor
|
|||
}
|
||||
|
||||
$item = [
|
||||
'author-id' => Contact::getIdForURL($activity['actor']),
|
||||
'author-id' => Contact::getIdForURL($activity['actor']),
|
||||
'author-link' => $activity['actor'],
|
||||
];
|
||||
|
||||
|
@ -2134,7 +2136,7 @@ class Processor
|
|||
private static function transmitPendingEvents(int $cid, int $uid)
|
||||
{
|
||||
$account = DBA::selectFirst('account-user-view', ['ap-inbox', 'ap-sharedinbox'], ['id' => $cid]);
|
||||
$inbox = $account['ap-sharedinbox'] ?: $account['ap-inbox'];
|
||||
$inbox = $account['ap-sharedinbox'] ?: $account['ap-inbox'];
|
||||
|
||||
$events = DBA::select('event', ['id'], ["`uid` = ? AND `start` > ? AND `type` != ?", $uid, DateTimeFormat::utcNow(), 'birthday']);
|
||||
while ($event = DBA::fetch($events)) {
|
||||
|
@ -2334,7 +2336,7 @@ class Processor
|
|||
$check_id = false;
|
||||
|
||||
if (!empty($activity['object_actor'])) {
|
||||
$uid = User::getIdForURL($activity['object_actor']);
|
||||
$uid = User::getIdForURL($activity['object_actor']);
|
||||
} elseif (!empty($activity['receiver']) && (count($activity['receiver']) == 1)) {
|
||||
$uid = array_shift($activity['receiver']);
|
||||
$check_id = true;
|
||||
|
@ -2610,9 +2612,9 @@ class Processor
|
|||
*/
|
||||
public static function addToCallstack(array $callstack): array
|
||||
{
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
$functions = array_slice(array_column($trace, 'function'), 1);
|
||||
$function = array_shift($functions);
|
||||
$function = array_shift($functions);
|
||||
|
||||
if (in_array($function, $callstack)) {
|
||||
DI::logger()->notice('Callstack already contains "' . $function . '"', ['callstack' => $callstack]);
|
||||
|
|
|
@ -192,7 +192,7 @@ class Queue
|
|||
|
||||
if (!empty($entry['wid'])) {
|
||||
$worker = DI::appHelper()->getQueue();
|
||||
$wid = $worker['id'] ?? 0;
|
||||
$wid = $worker['id'] ?? 0;
|
||||
if ($entry['wid'] != $wid) {
|
||||
$workerqueue = DBA::selectFirst('workerqueue', ['pid'], ['id' => $entry['wid'], 'done' => false]);
|
||||
if (!empty($workerqueue['pid']) && posix_kill($workerqueue['pid'], 0)) {
|
||||
|
@ -327,8 +327,8 @@ class Queue
|
|||
return false;
|
||||
}
|
||||
$activity['recursion-depth'] = 0;
|
||||
$activity['callstack'] = Processor::addToCallstack($activity['callstack'] ?? []);
|
||||
$wid = Worker::add(Worker::PRIORITY_HIGH, 'FetchMissingActivity', $entry['in-reply-to-id'], $activity, '', Receiver::COMPLETION_ASYNC);
|
||||
$activity['callstack'] = Processor::addToCallstack($activity['callstack'] ?? []);
|
||||
$wid = Worker::add(Worker::PRIORITY_HIGH, 'FetchMissingActivity', $entry['in-reply-to-id'], $activity, '', Receiver::COMPLETION_ASYNC);
|
||||
Fetch::setWorkerId($entry['in-reply-to-id'], $wid);
|
||||
DI::logger()->debug('Fetch missing activity', ['wid' => $wid, 'id' => $entry['activity-id'], 'reply-to-id' => $entry['in-reply-to-id']]);
|
||||
self::retrial($id);
|
||||
|
@ -348,7 +348,7 @@ class Queue
|
|||
*/
|
||||
public static function processReplyByUri(string $uri, array $parent = []): int
|
||||
{
|
||||
$count = 0;
|
||||
$count = 0;
|
||||
$entries = DBA::select('inbox-entry', ['id'], ["`in-reply-to-id` = ? AND `object-id` != ?", $uri, $uri]);
|
||||
while ($entry = DBA::fetch($entries)) {
|
||||
$count += 1;
|
||||
|
|
|
@ -80,7 +80,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
foreach ($relays as $relay) {
|
||||
$contact = Contact::getByURLForUser($relay['url'], $item['uid'], false, ['id']);
|
||||
$contact = Contact::getByURLForUser($relay['url'], $item['uid'], false, ['id']);
|
||||
$inboxes[$relay['batch']][] = $contact['id'] ?? 0;
|
||||
}
|
||||
return $inboxes;
|
||||
|
@ -100,7 +100,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
$activity_id = self::activityIDFromContact($contact['id']);
|
||||
$success = self::sendActivity('Follow', $url, 0, $activity_id);
|
||||
$success = self::sendActivity('Follow', $url, 0, $activity_id);
|
||||
if ($success) {
|
||||
Contact::update(['rel' => Contact::FRIEND], ['id' => $contact['id']]);
|
||||
}
|
||||
|
@ -147,18 +147,18 @@ class Transmitter
|
|||
{
|
||||
if (empty($page)) {
|
||||
$cachekey = self::CACHEKEY_CONTACTS . $module . ':' . $owner['uid'];
|
||||
$result = DI::cache()->get($cachekey);
|
||||
$result = DI::cache()->get($cachekey);
|
||||
if (!$nocache && !is_null($result)) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = [
|
||||
'rel' => $rel,
|
||||
'uid' => $owner['uid'],
|
||||
'self' => false,
|
||||
'rel' => $rel,
|
||||
'uid' => $owner['uid'],
|
||||
'self' => false,
|
||||
'deleted' => false,
|
||||
'hidden' => false,
|
||||
'hidden' => false,
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
|
@ -170,9 +170,9 @@ class Transmitter
|
|||
|
||||
$modulePath = '/' . $module . '/';
|
||||
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data['id'] = DI::baseUrl() . $modulePath . $owner['nickname'];
|
||||
$data['type'] = 'OrderedCollection';
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data['id'] = DI::baseUrl() . $modulePath . $owner['nickname'];
|
||||
$data['type'] = 'OrderedCollection';
|
||||
$data['totalItems'] = $total;
|
||||
|
||||
if (!empty($page)) {
|
||||
|
@ -199,7 +199,7 @@ class Transmitter
|
|||
$data['first'] = DI::baseUrl() . $modulePath . $owner['nickname'] . '?page=1';
|
||||
} else {
|
||||
$data['type'] = 'OrderedCollectionPage';
|
||||
$list = [];
|
||||
$list = [];
|
||||
|
||||
$contacts = DBA::select('contact', ['url'], $condition, ['limit' => [($page - 1) * 100, 100]]);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
|
@ -238,7 +238,7 @@ class Transmitter
|
|||
{
|
||||
if (empty($page)) {
|
||||
$cachekey = self::CACHEKEY_FEATURED . $owner['uid'];
|
||||
$result = DI::cache()->get($cachekey);
|
||||
$result = DI::cache()->get($cachekey);
|
||||
if (!$nocache && !is_null($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class Transmitter
|
|||
];
|
||||
|
||||
$condition = DBA::mergeConditions($condition, [
|
||||
'uid' => $owner['uid'],
|
||||
'uid' => $owner['uid'],
|
||||
'author-id' => $owner_cid,
|
||||
'private' => [Item::PUBLIC, Item::UNLISTED],
|
||||
'gravity' => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
|
||||
|
@ -265,9 +265,9 @@ class Transmitter
|
|||
|
||||
$count = Post::count($condition);
|
||||
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data['id'] = DI::baseUrl() . '/featured/' . $owner['nickname'];
|
||||
$data['type'] = 'OrderedCollection';
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data['id'] = DI::baseUrl() . '/featured/' . $owner['nickname'];
|
||||
$data['type'] = 'OrderedCollection';
|
||||
$data['totalItems'] = $count;
|
||||
|
||||
if (!empty($page)) {
|
||||
|
@ -278,7 +278,7 @@ class Transmitter
|
|||
$items = Post::select(['id'], $condition, ['limit' => 20, 'order' => ['created' => true]]);
|
||||
} else {
|
||||
$data['type'] = 'OrderedCollectionPage';
|
||||
$items = Post::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
|
||||
$items = Post::select(['id'], $condition, ['limit' => [($page - 1) * 20, 20], 'order' => ['created' => true]]);
|
||||
}
|
||||
$list = [];
|
||||
|
||||
|
@ -317,7 +317,7 @@ class Transmitter
|
|||
return [
|
||||
'id' => (string)DI::baseUrl() . '/friendica',
|
||||
'type' => 'Application',
|
||||
'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
|
||||
'name' => App::PLATFORM . " '" . App::CODENAME . "' " . App::VERSION . '-' . DB_UPDATE_VERSION,
|
||||
'url' => (string)DI::baseUrl(),
|
||||
];
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ class Transmitter
|
|||
throw new HTTPException\NotFoundException('User not found.');
|
||||
}
|
||||
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data = ['@context' => ActivityPub::CONTEXT];
|
||||
$data['id'] = $owner['url'];
|
||||
|
||||
if (!empty($owner['guid'])) {
|
||||
|
@ -360,11 +360,11 @@ class Transmitter
|
|||
}
|
||||
|
||||
$data['preferredUsername'] = $owner['nick'];
|
||||
$data['name'] = $full ? $owner['name'] : $owner['nick'];
|
||||
$data['name'] = $full ? $owner['name'] : $owner['nick'];
|
||||
|
||||
if ($full && !empty($owner['country-name'] . $owner['region'] . $owner['locality'])) {
|
||||
$data['vcard:hasAddress'] = [
|
||||
'@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
|
||||
'@type' => 'vcard:Home', 'vcard:country-name' => $owner['country-name'],
|
||||
'vcard:region' => $owner['region'], 'vcard:locality' => $owner['locality']
|
||||
];
|
||||
}
|
||||
|
@ -384,12 +384,12 @@ class Transmitter
|
|||
}
|
||||
}
|
||||
|
||||
$data['url'] = $owner['url'];
|
||||
$data['url'] = $owner['url'];
|
||||
$data['manuallyApprovesFollowers'] = in_array($owner['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP]);
|
||||
$data['discoverable'] = (bool)$owner['net-publish'] && $full;
|
||||
$data['publicKey'] = [
|
||||
'id' => $owner['url'] . '#main-key',
|
||||
'owner' => $owner['url'],
|
||||
$data['discoverable'] = (bool)$owner['net-publish'] && $full;
|
||||
$data['publicKey'] = [
|
||||
'id' => $owner['url'] . '#main-key',
|
||||
'owner' => $owner['url'],
|
||||
'publicKeyPem' => $owner['pubkey']
|
||||
];
|
||||
$data['endpoints'] = ['sharedInbox' => DI::baseUrl() . '/inbox'];
|
||||
|
@ -420,8 +420,8 @@ class Transmitter
|
|||
|
||||
foreach (DI::profileField()->selectByContactId(0, $uid) as $profile_field) {
|
||||
$custom_fields[] = [
|
||||
'type' => 'PropertyValue',
|
||||
'name' => $profile_field->label,
|
||||
'type' => 'PropertyValue',
|
||||
'name' => $profile_field->label,
|
||||
'value' => BBCode::convertForUriId($owner['uri-id'], $profile_field->value)
|
||||
];
|
||||
};
|
||||
|
@ -446,7 +446,7 @@ class Transmitter
|
|||
private static function getActorArrayByCid(int $cid): array
|
||||
{
|
||||
$contact = Contact::getById($cid);
|
||||
$data = [
|
||||
$data = [
|
||||
'id' => $contact['url'],
|
||||
'type' => $data['type'] = ActivityPub::ACCOUNT_TYPES[$contact['contact-type']],
|
||||
'url' => $contact['alias'],
|
||||
|
@ -473,12 +473,12 @@ class Transmitter
|
|||
public static function getDeletedUser(string $username): array
|
||||
{
|
||||
return [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/profile/' . $username,
|
||||
'type' => 'Tombstone',
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/profile/' . $username,
|
||||
'type' => 'Tombstone',
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'deleted' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'deleted' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ class Transmitter
|
|||
$parent_profile = APContact::getByURL($parent['author-link']);
|
||||
|
||||
$item_profile = APContact::getByURL($item['author-link']);
|
||||
$exclude[] = $item['author-link'];
|
||||
$exclude[] = $item['author-link'];
|
||||
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$exclude[] = $item['owner-link'];
|
||||
|
@ -591,7 +591,7 @@ class Transmitter
|
|||
|
||||
$parent = Post::selectFirst(['causer-link', 'post-reason'], ['id' => $item['parent']]);
|
||||
if (!empty($parent) && ($parent['post-reason'] == Item::PR_ANNOUNCEMENT) && !empty($parent['causer-link'])) {
|
||||
$profile = APContact::getByURL($parent['causer-link'], false);
|
||||
$profile = APContact::getByURL($parent['causer-link'], false);
|
||||
$is_group_thread = isset($profile['type']) && $profile['type'] == 'Group';
|
||||
} else {
|
||||
$is_group_thread = false;
|
||||
|
@ -607,7 +607,7 @@ class Transmitter
|
|||
}
|
||||
$profile = APContact::getByURL($tag['url'], false);
|
||||
if (!empty($profile) && ($profile['type'] == 'Group')) {
|
||||
$audience[] = $tag['url'];
|
||||
$audience[] = $tag['url'];
|
||||
$is_group_thread = true;
|
||||
}
|
||||
}
|
||||
|
@ -798,7 +798,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
if (!empty($item['quote-uri-id']) && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||
$quoted = Post::selectFirst(['author-link'], ['uri-id' => $item['quote-uri-id']]);
|
||||
$quoted = Post::selectFirst(['author-link'], ['uri-id' => $item['quote-uri-id']]);
|
||||
$profile = APContact::getByURL($quoted['author-link'], false);
|
||||
if (!empty($profile)) {
|
||||
$data['cc'][] = $profile['url'];
|
||||
|
@ -982,12 +982,12 @@ class Transmitter
|
|||
public static function fetchTargetInboxesforUser(int $uid): array
|
||||
{
|
||||
$condition = [
|
||||
'uid' => $uid,
|
||||
'self' => false,
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
'network' => Protocol::FEDERATED,
|
||||
'uid' => $uid,
|
||||
'self' => false,
|
||||
'archive' => false,
|
||||
'pending' => false,
|
||||
'blocked' => false,
|
||||
'network' => Protocol::FEDERATED,
|
||||
];
|
||||
|
||||
if (!empty($uid)) {
|
||||
|
@ -1149,7 +1149,7 @@ class Transmitter
|
|||
$mail['content-warning'] = $mail['title'];
|
||||
$mail['title'] = '';
|
||||
} else {
|
||||
$mail['content-warning'] = '';
|
||||
$mail['content-warning'] = '';
|
||||
}
|
||||
$mail['sensitive'] = false;
|
||||
$mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
|
||||
|
@ -1196,12 +1196,12 @@ class Transmitter
|
|||
$data = [];
|
||||
}
|
||||
|
||||
$data['id'] = $mail['uri'] . '/Create';
|
||||
$data['type'] = 'Create';
|
||||
$data['actor'] = $mail['author-link'];
|
||||
$data['published'] = DateTimeFormat::utc($mail['created'] . '+00:00', DateTimeFormat::ATOM);
|
||||
$data['id'] = $mail['uri'] . '/Create';
|
||||
$data['type'] = 'Create';
|
||||
$data['actor'] = $mail['author-link'];
|
||||
$data['published'] = DateTimeFormat::utc($mail['created'] . '+00:00', DateTimeFormat::ATOM);
|
||||
$data['instrument'] = self::getService();
|
||||
$data = array_merge($data, self::createPermissionBlockForItem($mail, true));
|
||||
$data = array_merge($data, self::createPermissionBlockForItem($mail, true));
|
||||
|
||||
if (empty($data['to']) && !empty($data['cc'])) {
|
||||
$data['to'] = $data['cc'];
|
||||
|
@ -1215,7 +1215,7 @@ class Transmitter
|
|||
unset($data['bcc']);
|
||||
unset($data['audience']);
|
||||
|
||||
$object['to'] = $data['to'];
|
||||
$object['to'] = $data['to'];
|
||||
$object['tag'] = [['type' => 'Mention', 'href' => $object['to'][0], 'name' => '']];
|
||||
|
||||
unset($object['cc']);
|
||||
|
@ -1403,7 +1403,8 @@ class Transmitter
|
|||
}
|
||||
|
||||
if ($type == 'Delete') {
|
||||
$data['id'] = Item::newURI($item['guid']) . '/' . $type;;
|
||||
$data['id'] = Item::newURI($item['guid']) . '/' . $type;
|
||||
;
|
||||
} elseif (($item['gravity'] == Item::GRAVITY_ACTIVITY) && ($type != 'Undo')) {
|
||||
$data['id'] = $item['uri'];
|
||||
} else {
|
||||
|
@ -1439,7 +1440,7 @@ class Transmitter
|
|||
} elseif ($data['type'] == 'Announce') {
|
||||
if ($item['verb'] == ACTIVITY::ANNOUNCE) {
|
||||
if ($announce_activity) {
|
||||
$anounced_item = Post::selectFirst(['uid'], ['uri-id' => $item['thr-parent-id'], 'origin' => true]);
|
||||
$anounced_item = Post::selectFirst(['uid'], ['uri-id' => $item['thr-parent-id'], 'origin' => true]);
|
||||
$data['object'] = self::createActivityFromUriId($item['thr-parent-id'], $anounced_item['uid'] ?? 0);
|
||||
unset($data['object']['@context']);
|
||||
} else {
|
||||
|
@ -1505,7 +1506,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
if (!empty($coord['lat']) && !empty($coord['lon'])) {
|
||||
$location['latitude'] = $coord['lat'];
|
||||
$location['latitude'] = $coord['lat'];
|
||||
$location['longitude'] = $coord['lon'];
|
||||
}
|
||||
|
||||
|
@ -1528,7 +1529,7 @@ class Transmitter
|
|||
'name' => $name,
|
||||
'icon' => [
|
||||
'type' => 'Image',
|
||||
'url' => $url,
|
||||
'url' => $url,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -1550,7 +1551,7 @@ class Transmitter
|
|||
$terms = Tag::getByURIId($item['uri-id'], [Tag::HASHTAG, Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
|
||||
foreach ($terms as $term) {
|
||||
if ($term['type'] == Tag::HASHTAG) {
|
||||
$url = DI::baseUrl() . '/search?tag=' . urlencode($term['name']);
|
||||
$url = DI::baseUrl() . '/search?tag=' . urlencode($term['name']);
|
||||
$tags[] = ['type' => 'Hashtag', 'href' => $url, 'name' => '#' . $term['name']];
|
||||
} else {
|
||||
$contact = Contact::getByURL($term['url'], false, ['addr']);
|
||||
|
@ -1606,10 +1607,10 @@ class Transmitter
|
|||
$urls[] = $attachment['url'];
|
||||
|
||||
$attach = [
|
||||
'type' => 'Document',
|
||||
'type' => 'Document',
|
||||
'mediaType' => $attachment['mimetype'],
|
||||
'url' => $attachment['url'],
|
||||
'name' => $attachment['description']
|
||||
'url' => $attachment['url'],
|
||||
'name' => $attachment['description']
|
||||
];
|
||||
|
||||
if (!empty($attachment['height'])) {
|
||||
|
@ -1692,9 +1693,9 @@ class Transmitter
|
|||
*/
|
||||
private static function createEvent(array $item): array
|
||||
{
|
||||
$event = [];
|
||||
$event['name'] = $item['event-summary'];
|
||||
$event['content'] = BBCode::convertForUriId($item['uri-id'], $item['event-desc'], BBCode::ACTIVITYPUB);
|
||||
$event = [];
|
||||
$event['name'] = $item['event-summary'];
|
||||
$event['content'] = BBCode::convertForUriId($item['uri-id'], $item['event-desc'], BBCode::ACTIVITYPUB);
|
||||
$event['startTime'] = DateTimeFormat::utc($item['event-start'], 'c');
|
||||
|
||||
if (!$item['event-nofinish']) {
|
||||
|
@ -1702,7 +1703,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
if (!empty($item['event-location'])) {
|
||||
$item['location'] = $item['event-location'];
|
||||
$item['location'] = $item['event-location'];
|
||||
$event['location'] = self::createLocation($item);
|
||||
}
|
||||
|
||||
|
@ -1732,7 +1733,7 @@ class Transmitter
|
|||
// But to not risk compatibility issues we currently perform the changes only for communities.
|
||||
if ($item['gravity'] == Item::GRAVITY_PARENT) {
|
||||
$isCommunityPost = !empty(Tag::getByURIId($item['uri-id'], [Tag::EXCLUSIVE_MENTION]));
|
||||
$links = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
|
||||
$links = Post\Media::getByURIId($item['uri-id'], [Post\Media::HTML]);
|
||||
if ($isCommunityPost && (count($links) == 1)) {
|
||||
$link = $links[0]['url'];
|
||||
}
|
||||
|
@ -1763,10 +1764,10 @@ class Transmitter
|
|||
$title = '';
|
||||
break;
|
||||
case ActivityPub::ARTICLE_EMBED_TITLE:
|
||||
$type = 'Note';
|
||||
$type = 'Note';
|
||||
$item['raw-body'] = '[b]' . $title . "[/b]\n\n" . $item['raw-body'];
|
||||
$item['body'] = '[b]' . $title . "[/b]\n\n" . $item['body'];
|
||||
$title = '';
|
||||
$title = '';
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -1781,8 +1782,8 @@ class Transmitter
|
|||
$type = 'Tombstone';
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['id'] = $item['uri'];
|
||||
$data = [];
|
||||
$data['id'] = $item['uri'];
|
||||
$data['type'] = $type;
|
||||
|
||||
if ($item['deleted']) {
|
||||
|
@ -1796,7 +1797,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
$data['diaspora:guid'] = $item['guid'];
|
||||
$data['published'] = DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM);
|
||||
$data['published'] = DateTimeFormat::utc($item['created'] . '+00:00', DateTimeFormat::ATOM);
|
||||
|
||||
if ($item['created'] != $item['edited']) {
|
||||
$data['updated'] = DateTimeFormat::utc($item['edited'] . '+00:00', DateTimeFormat::ATOM);
|
||||
|
@ -1832,7 +1833,7 @@ class Transmitter
|
|||
|
||||
$item = Post\Media::addHTMLAttachmentToItem($item);
|
||||
|
||||
$body = $item['body'];
|
||||
$body = $item['body'];
|
||||
$emojis = [];
|
||||
if ($type == 'Note') {
|
||||
$body = $item['raw-body'] ?? self::removePictures($body);
|
||||
|
@ -1876,10 +1877,10 @@ class Transmitter
|
|||
|
||||
if (!empty($item['quote-uri-id']) && ($item['quote-uri-id'] != $item['uri-id'])) {
|
||||
if (Post::exists(['uri-id' => $item['quote-uri-id'], 'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN]])) {
|
||||
$real_quote = true;
|
||||
$real_quote = true;
|
||||
$data['_misskey_content'] = BBCode::removeSharedData($body);
|
||||
$data['quoteUrl'] = $item['quote-uri'];
|
||||
$body = DI::contentItem()->addShareLink($body, $item['quote-uri-id']);
|
||||
$data['quoteUrl'] = $item['quote-uri'];
|
||||
$body = DI::contentItem()->addShareLink($body, $item['quote-uri-id']);
|
||||
} else {
|
||||
$body = DI::contentItem()->addSharedPost($item, $body);
|
||||
}
|
||||
|
@ -1920,7 +1921,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
$data['attachment'] = self::createAttachmentList($item);
|
||||
$data['tag'] = array_merge(self::createTagList($item, $data['quoteUrl'] ?? ''), $emojis);
|
||||
$data['tag'] = array_merge(self::createTagList($item, $data['quoteUrl'] ?? ''), $emojis);
|
||||
|
||||
if (empty($data['location']) && (!empty($item['coord']) || !empty($item['location']))) {
|
||||
$data['location'] = self::createLocation($item);
|
||||
|
@ -1978,10 +1979,10 @@ class Transmitter
|
|||
$target = XML::parseString($item['target']);
|
||||
|
||||
$activity['diaspora:guid'] = $item['guid'];
|
||||
$activity['actor'] = $item['author-link'];
|
||||
$activity['target'] = (string)$target->id;
|
||||
$activity['summary'] = BBCode::toPlaintext($item['body']);
|
||||
$activity['object'] = ['id' => (string)$object->id, 'type' => 'tag', 'name' => (string)$object->title, 'content' => (string)$object->content];
|
||||
$activity['actor'] = $item['author-link'];
|
||||
$activity['target'] = (string)$target->id;
|
||||
$activity['summary'] = BBCode::toPlaintext($item['body']);
|
||||
$activity['object'] = ['id' => (string)$object->id, 'type' => 'tag', 'name' => (string)$object->title, 'content' => (string)$object->content];
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
@ -1999,23 +2000,23 @@ class Transmitter
|
|||
private static function createAnnounce(array $item, array $activity, bool $api_mode = false): array
|
||||
{
|
||||
$orig_body = $item['body'];
|
||||
$announce = self::getAnnounceArray($item);
|
||||
$announce = self::getAnnounceArray($item);
|
||||
if (empty($announce)) {
|
||||
$activity['type'] = 'Create';
|
||||
$activity['type'] = 'Create';
|
||||
$activity['object'] = self::createNote($item, $api_mode);
|
||||
return $activity;
|
||||
}
|
||||
|
||||
if (empty($announce['comment'])) {
|
||||
// Pure announce, without a quote
|
||||
$activity['type'] = 'Announce';
|
||||
$activity['type'] = 'Announce';
|
||||
$activity['object'] = $announce['object']['uri'];
|
||||
return $activity;
|
||||
}
|
||||
|
||||
// Quote
|
||||
$activity['type'] = 'Create';
|
||||
$item['body'] = $announce['comment'] . "\n" . $announce['object']['plink'];
|
||||
$activity['type'] = 'Create';
|
||||
$item['body'] = $announce['comment'] . "\n" . $announce['object']['plink'];
|
||||
$activity['object'] = self::createNote($item, $api_mode);
|
||||
|
||||
/// @todo Finally decide how to implement this in AP. This is a possible way:
|
||||
|
@ -2104,15 +2105,15 @@ class Transmitter
|
|||
$suggestion = DI::fsuggest()->selectOneById($suggestion_id);
|
||||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Announce',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $suggestion->url,
|
||||
'content' => $suggestion->note,
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Announce',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $suggestion->url,
|
||||
'content' => $suggestion->note,
|
||||
'instrument' => self::getService(),
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
@ -2132,15 +2133,15 @@ class Transmitter
|
|||
public static function sendProfileRelocation(array $owner, string $inbox): bool
|
||||
{
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'dfrn:relocate',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $owner['url'],
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'dfrn:relocate',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $owner['url'],
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'instrument' => self::getService(),
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
@ -2165,15 +2166,15 @@ class Transmitter
|
|||
}
|
||||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Delete',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $owner['url'],
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Delete',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $owner['url'],
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'instrument' => self::getService(),
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
'to' => [ActivityPub::PUBLIC_COLLECTION],
|
||||
'cc' => []
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
@ -2197,15 +2198,15 @@ class Transmitter
|
|||
$profile = APContact::getByURL($owner['url']);
|
||||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Update',
|
||||
'actor' => $owner['url'],
|
||||
'object' => self::getProfile($owner['uid']),
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Update',
|
||||
'actor' => $owner['url'],
|
||||
'object' => self::getProfile($owner['uid']),
|
||||
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['followers']],
|
||||
'cc' => []
|
||||
'to' => [$profile['followers']],
|
||||
'cc' => []
|
||||
];
|
||||
|
||||
$signed = LDSignature::sign($data, $owner);
|
||||
|
@ -2245,13 +2246,13 @@ class Transmitter
|
|||
}
|
||||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => $id,
|
||||
'type' => $activity,
|
||||
'actor' => $owner['url'],
|
||||
'object' => $profile['url'],
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => $id,
|
||||
'type' => $activity,
|
||||
'actor' => $owner['url'],
|
||||
'object' => $profile['url'],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
'to' => [$profile['url']],
|
||||
];
|
||||
|
||||
DI::logger()->info('Sending activity ' . $activity . ' to ' . $target . ' for user ' . $uid);
|
||||
|
@ -2292,7 +2293,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
$condition = [
|
||||
'verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||
'verb' => Activity::FOLLOW, 'uid' => 0, 'parent-uri' => $object,
|
||||
'author-id' => Contact::getPublicIdByUserId($uid)
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
|
@ -2303,13 +2304,13 @@ class Transmitter
|
|||
$owner = User::getOwnerDataById($uid);
|
||||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Follow',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $object,
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Follow',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $object,
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
'to' => [$profile['url']],
|
||||
];
|
||||
|
||||
DI::logger()->info('Sending follow ' . $object . ' to ' . $target . ' for user ' . $uid);
|
||||
|
@ -2344,17 +2345,17 @@ class Transmitter
|
|||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Accept',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $id,
|
||||
'type' => 'Follow',
|
||||
'actor' => $profile['url'],
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Accept',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $id,
|
||||
'type' => 'Follow',
|
||||
'actor' => $profile['url'],
|
||||
'object' => $owner['url']
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
'to' => [$profile['url']],
|
||||
];
|
||||
|
||||
DI::logger()->debug('Sending accept to ' . $target . ' for user ' . $uid . ' with id ' . $id);
|
||||
|
@ -2383,17 +2384,17 @@ class Transmitter
|
|||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Reject',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $objectId,
|
||||
'type' => 'Follow',
|
||||
'actor' => $profile['url'],
|
||||
'id' => DI::baseUrl() . '/activity/' . System::createGUID(),
|
||||
'type' => 'Reject',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $objectId,
|
||||
'type' => 'Follow',
|
||||
'actor' => $profile['url'],
|
||||
'object' => $owner['url']
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
'to' => [$profile['url']],
|
||||
];
|
||||
|
||||
DI::logger()->debug('Sending reject to ' . $target . ' for user ' . $owner['uid'] . ' with id ' . $objectId);
|
||||
|
@ -2430,17 +2431,17 @@ class Transmitter
|
|||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => $objectId,
|
||||
'type' => 'Undo',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $object_id,
|
||||
'type' => 'Follow',
|
||||
'actor' => $owner['url'],
|
||||
'id' => $objectId,
|
||||
'type' => 'Undo',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $object_id,
|
||||
'type' => 'Follow',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $profile['url']
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
'to' => [$profile['url']],
|
||||
];
|
||||
|
||||
DI::logger()->info('Sending undo to ' . $target . ' for user ' . $owner['uid'] . ' with id ' . $objectId);
|
||||
|
@ -2477,17 +2478,17 @@ class Transmitter
|
|||
|
||||
$data = [
|
||||
'@context' => ActivityPub::CONTEXT,
|
||||
'id' => $objectId,
|
||||
'type' => 'Undo',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $object_id,
|
||||
'type' => 'Block',
|
||||
'actor' => $owner['url'],
|
||||
'id' => $objectId,
|
||||
'type' => 'Undo',
|
||||
'actor' => $owner['url'],
|
||||
'object' => [
|
||||
'id' => $object_id,
|
||||
'type' => 'Block',
|
||||
'actor' => $owner['url'],
|
||||
'object' => $profile['url']
|
||||
],
|
||||
'instrument' => self::getService(),
|
||||
'to' => [$profile['url']],
|
||||
'to' => [$profile['url']],
|
||||
];
|
||||
|
||||
DI::logger()->info('Sending undo to ' . $target . ' for user ' . $owner['uid'] . ' with id ' . $objectId);
|
||||
|
|
|
@ -45,7 +45,6 @@ use GuzzleHttp\Psr7\Uri;
|
|||
*/
|
||||
class DFRN
|
||||
{
|
||||
|
||||
const TOP_LEVEL = 0; // Top level posting
|
||||
const REPLY = 1; // Regular reply that is stored locally
|
||||
const REPLY_RC = 2; // Reply that will be relayed
|
||||
|
@ -64,27 +63,27 @@ class DFRN
|
|||
public static function getImporter(int $cid, int $uid = 0): array
|
||||
{
|
||||
$condition = ['id' => $cid, 'blocked' => false, 'pending' => false];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$contact['cpubkey'] = $contact['pubkey'];
|
||||
$contact['cprvkey'] = $contact['prvkey'];
|
||||
$contact['cpubkey'] = $contact['pubkey'];
|
||||
$contact['cprvkey'] = $contact['prvkey'];
|
||||
$contact['senderName'] = $contact['name'];
|
||||
|
||||
if ($uid != 0) {
|
||||
$condition = ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
|
||||
$user = DBA::selectFirst('user', [], $condition);
|
||||
$user = DBA::selectFirst('user', [], $condition);
|
||||
if (!DBA::isResult($user)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$user['importer_uid'] = $user['uid'];
|
||||
$user['uprvkey'] = $user['prvkey'];
|
||||
$user['uprvkey'] = $user['prvkey'];
|
||||
} else {
|
||||
$user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC',
|
||||
'nickname' => '', 'page-flags' => 0, 'account-type' => 0, 'prvnets' => 0];
|
||||
'nickname' => '', 'page-flags' => 0, 'account-type' => 0, 'prvnets' => 0];
|
||||
}
|
||||
|
||||
return array_merge($contact, $user);
|
||||
|
@ -105,7 +104,7 @@ class DFRN
|
|||
*/
|
||||
public static function entries(array $items, array $owner): string
|
||||
{
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = self::addHeader($doc, $owner, 'dfrn:owner', '', false);
|
||||
|
@ -118,7 +117,7 @@ class DFRN
|
|||
// These values aren't sent when sending from the queue.
|
||||
/// @todo Check if we can set these values from the queue or if they are needed at all.
|
||||
$item['entry:comment-allow'] = ($item['entry:comment-allow'] ?? '') ?: true;
|
||||
$item['entry:cid'] = $item['entry:cid'] ?? 0;
|
||||
$item['entry:cid'] = $item['entry:cid'] ?? 0;
|
||||
|
||||
$entry = self::entry($doc, 'text', $item, $owner, $item['entry:comment-allow'], $item['entry:cid']);
|
||||
if (isset($entry)) {
|
||||
|
@ -166,9 +165,9 @@ class DFRN
|
|||
$owner = ['uid' => 0, 'nick' => 'feed-item'];
|
||||
}
|
||||
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
$type = 'html';
|
||||
$type = 'html';
|
||||
|
||||
if ($conversation) {
|
||||
$root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed');
|
||||
|
@ -210,12 +209,12 @@ class DFRN
|
|||
*/
|
||||
public static function mail(array $mail, array $owner): string
|
||||
{
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = self::addHeader($doc, $owner, 'dfrn:owner', '', false);
|
||||
|
||||
$mailElement = $doc->createElement('dfrn:mail');
|
||||
$mailElement = $doc->createElement('dfrn:mail');
|
||||
$senderElement = $doc->createElement('dfrn:sender');
|
||||
|
||||
XML::addElement($doc, $senderElement, 'dfrn:name', $owner['name']);
|
||||
|
@ -247,7 +246,7 @@ class DFRN
|
|||
*/
|
||||
public static function fsuggest(array $item, array $owner): string
|
||||
{
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = self::addHeader($doc, $owner, 'dfrn:owner', '', false);
|
||||
|
@ -293,7 +292,7 @@ class DFRN
|
|||
$photos[$p['scale']] = DI::baseUrl() . '/photo/' . $p['resource-id'] . '-' . $p['scale'] . Images::getExtensionByMimeType($p['type']);
|
||||
}
|
||||
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = self::addHeader($doc, $owner, 'dfrn:owner', '', false);
|
||||
|
@ -411,10 +410,10 @@ class DFRN
|
|||
if (DBA::isResult($profile)) {
|
||||
$tmp_dob = substr($profile['dob'], 5);
|
||||
if (intval($tmp_dob)) {
|
||||
$y = DateTimeFormat::timezoneNow($tz, 'Y');
|
||||
$bd = $y . '-' . $tmp_dob . ' 00:00';
|
||||
$y = DateTimeFormat::timezoneNow($tz, 'Y');
|
||||
$bd = $y . '-' . $tmp_dob . ' 00:00';
|
||||
$t_dob = strtotime($bd);
|
||||
$now = strtotime(DateTimeFormat::timezoneNow($tz));
|
||||
$now = strtotime(DateTimeFormat::timezoneNow($tz));
|
||||
if ($t_dob < $now) {
|
||||
$bd = (int) $y + 1 . '-' . $tmp_dob . ' 00:00';
|
||||
}
|
||||
|
@ -457,11 +456,11 @@ class DFRN
|
|||
XML::addElement($doc, $author, 'dfrn:handle', $owner['addr'], $attributes);
|
||||
|
||||
$attributes = [
|
||||
'rel' => 'photo',
|
||||
'type' => 'image/jpeg',
|
||||
'media:width' => Proxy::PIXEL_SMALL,
|
||||
'rel' => 'photo',
|
||||
'type' => 'image/jpeg',
|
||||
'media:width' => Proxy::PIXEL_SMALL,
|
||||
'media:height' => Proxy::PIXEL_SMALL,
|
||||
'href' => User::getAvatarUrl($owner, Proxy::SIZE_SMALL),
|
||||
'href' => User::getAvatarUrl($owner, Proxy::SIZE_SMALL),
|
||||
];
|
||||
|
||||
if (!$public || !$hide) {
|
||||
|
@ -489,9 +488,11 @@ class DFRN
|
|||
}
|
||||
|
||||
// Only show contact details when we are allowed to
|
||||
$profile = DBA::selectFirst('owner-view',
|
||||
$profile = DBA::selectFirst(
|
||||
'owner-view',
|
||||
['about', 'name', 'homepage', 'nickname', 'timezone', 'locality', 'region', 'country-name', 'pub_keywords', 'xmpp', 'dob'],
|
||||
['uid' => $owner['uid'], 'hidewall' => false]);
|
||||
['uid' => $owner['uid'], 'hidewall' => false]
|
||||
);
|
||||
if (DBA::isResult($profile)) {
|
||||
XML::addElement($doc, $author, 'poco:displayName', $profile['name']);
|
||||
XML::addElement($doc, $author, 'poco:updated', $namdate);
|
||||
|
@ -578,20 +579,20 @@ class DFRN
|
|||
/// - Check real image type and image size
|
||||
/// - Check which of these elements we should use
|
||||
$attributes = [
|
||||
'rel' => 'photo',
|
||||
'type' => 'image/jpeg',
|
||||
'media:width' => 80,
|
||||
'rel' => 'photo',
|
||||
'type' => 'image/jpeg',
|
||||
'media:width' => 80,
|
||||
'media:height' => 80,
|
||||
'href' => $contact['photo'],
|
||||
'href' => $contact['photo'],
|
||||
];
|
||||
XML::addElement($doc, $author, 'link', '', $attributes);
|
||||
|
||||
$attributes = [
|
||||
'rel' => 'avatar',
|
||||
'type' => 'image/jpeg',
|
||||
'media:width' => 80,
|
||||
'rel' => 'avatar',
|
||||
'type' => 'image/jpeg',
|
||||
'media:width' => 80,
|
||||
'media:height' => 80,
|
||||
'href' => $contact['photo'],
|
||||
'href' => $contact['photo'],
|
||||
];
|
||||
XML::addElement($doc, $author, 'link', '', $attributes);
|
||||
}
|
||||
|
@ -680,8 +681,8 @@ class DFRN
|
|||
{
|
||||
foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT]) as $attachment) {
|
||||
$attributes = ['rel' => 'enclosure',
|
||||
'href' => $attachment['url'],
|
||||
'type' => $attachment['mimetype']];
|
||||
'href' => $attachment['url'],
|
||||
'type' => $attachment['mimetype']];
|
||||
|
||||
if (!empty($attachment['size'])) {
|
||||
$attributes['length'] = intval($attachment['size']);
|
||||
|
@ -771,8 +772,8 @@ class DFRN
|
|||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$parent = Post::selectFirst(['guid', 'plink'], ['uri' => $item['thr-parent'], 'uid' => $item['uid']]);
|
||||
if (DBA::isResult($parent)) {
|
||||
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
|
||||
"href" => $parent['plink'],
|
||||
$attributes = ["ref" => $item['thr-parent'], "type" => "text/html",
|
||||
"href" => $parent['plink'],
|
||||
"dfrn:diaspora_guid" => $parent['guid']];
|
||||
XML::addElement($doc, $entry, "thr:in-reply-to", "", $attributes);
|
||||
}
|
||||
|
@ -781,7 +782,7 @@ class DFRN
|
|||
// Add conversation data. This is used for OStatus
|
||||
$attributes = [
|
||||
'href' => $item['conversation'],
|
||||
'ref' => $item['conversation'],
|
||||
'ref' => $item['conversation'],
|
||||
];
|
||||
|
||||
XML::addElement($doc, $entry, 'ostatus:conversation', $item['conversation'], $attributes);
|
||||
|
@ -806,7 +807,7 @@ class DFRN
|
|||
'link',
|
||||
'',
|
||||
[
|
||||
'rel' => 'alternate',
|
||||
'rel' => 'alternate',
|
||||
'type' => 'text/html',
|
||||
'href' => DI::baseUrl() . '/display/' . $item['guid']
|
||||
],
|
||||
|
@ -888,7 +889,7 @@ class DFRN
|
|||
|
||||
foreach ($mentioned as $mention) {
|
||||
$condition = ['uid' => $owner['uid'], 'nurl' => Strings::normaliseLink($mention)];
|
||||
$contact = DBA::selectFirst('contact', ['contact-type'], $condition);
|
||||
$contact = DBA::selectFirst('contact', ['contact-type'], $condition);
|
||||
|
||||
if (DBA::isResult($contact) && ($contact['contact-type'] == Contact::TYPE_COMMUNITY)) {
|
||||
XML::addElement(
|
||||
|
@ -897,9 +898,9 @@ class DFRN
|
|||
'link',
|
||||
'',
|
||||
[
|
||||
'rel' => 'mentioned',
|
||||
'rel' => 'mentioned',
|
||||
'ostatus:object-type' => Activity\ObjectType::GROUP,
|
||||
'href' => $mention,
|
||||
'href' => $mention,
|
||||
],
|
||||
);
|
||||
} else {
|
||||
|
@ -909,9 +910,9 @@ class DFRN
|
|||
'link',
|
||||
'',
|
||||
[
|
||||
'rel' => 'mentioned',
|
||||
'rel' => 'mentioned',
|
||||
'ostatus:object-type' => Activity\ObjectType::PERSON,
|
||||
'href' => $mention,
|
||||
'href' => $mention,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -939,7 +940,7 @@ class DFRN
|
|||
if (empty($contact['addr'])) {
|
||||
DI::logger()->notice('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
|
||||
if (Contact::updateFromProbe($contact['id'])) {
|
||||
$new_contact = DBA::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
|
||||
$new_contact = DBA::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
|
||||
$contact['addr'] = $new_contact['addr'];
|
||||
}
|
||||
|
||||
|
@ -963,10 +964,10 @@ class DFRN
|
|||
|
||||
// Create the endpoint for public posts. This is some WIP and should later be added to the probing
|
||||
if ($public_batch && empty($contact['batch'])) {
|
||||
$parts = parse_url($contact['notify']);
|
||||
$parts = parse_url($contact['notify']);
|
||||
$path_parts = explode('/', $parts['path']);
|
||||
array_pop($path_parts);
|
||||
$parts['path'] = implode('/', $path_parts);
|
||||
$parts['path'] = implode('/', $path_parts);
|
||||
$contact['batch'] = (string)Uri::fromParts($parts);
|
||||
}
|
||||
|
||||
|
@ -1043,7 +1044,7 @@ class DFRN
|
|||
*/
|
||||
private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, array $importer, string $element, bool $onlyfetch, string $xml = ''): array
|
||||
{
|
||||
$author = [];
|
||||
$author = [];
|
||||
$author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context);
|
||||
$author["link"] = XML::getFirstNodeValue($xpath, $element."/atom:uri/text()", $context);
|
||||
|
||||
|
@ -1060,15 +1061,15 @@ class DFRN
|
|||
|
||||
if (DBA::isResult($contact_old)) {
|
||||
$author["contact-id"] = $contact_old["id"];
|
||||
$author["network"] = $contact_old["network"];
|
||||
$author["network"] = $contact_old["network"];
|
||||
} else {
|
||||
DI::logger()->info('Contact not found', ['condition' => $condition]);
|
||||
|
||||
$author["contact-unknown"] = true;
|
||||
$contact = Contact::getByURL($author["link"], null, ["id", "network"]);
|
||||
$author["contact-id"] = $contact["id"] ?? $importer["id"];
|
||||
$author["network"] = $contact["network"] ?? $importer["network"];
|
||||
$onlyfetch = true;
|
||||
$contact = Contact::getByURL($author["link"], null, ["id", "network"]);
|
||||
$author["contact-id"] = $contact["id"] ?? $importer["id"];
|
||||
$author["network"] = $contact["network"] ?? $importer["network"];
|
||||
$onlyfetch = true;
|
||||
}
|
||||
|
||||
// Until now we aren't serving different sizes - but maybe later
|
||||
|
@ -1076,7 +1077,7 @@ class DFRN
|
|||
/// @todo check if "avatar" or "photo" would be the best field in the specification
|
||||
$avatars = $xpath->query($element . "/atom:link[@rel='avatar']", $context);
|
||||
foreach ($avatars as $avatar) {
|
||||
$href = "";
|
||||
$href = "";
|
||||
$width = 0;
|
||||
foreach ($avatar->attributes as $attributes) {
|
||||
/// @TODO Rewrite these similar if() to one switch
|
||||
|
@ -1186,7 +1187,7 @@ class DFRN
|
|||
}
|
||||
|
||||
// Save the keywords into the contact table
|
||||
$tags = [];
|
||||
$tags = [];
|
||||
$tagelements = $xpath->evaluate($element . "/poco:tags/text()", $context);
|
||||
foreach ($tagelements as $tag) {
|
||||
$tags[$tag->nodeValue] = $tag->nodeValue;
|
||||
|
@ -1212,7 +1213,7 @@ class DFRN
|
|||
|
||||
if (!in_array($value, ["", "0000-00-00", DBA::NULL_DATE])) {
|
||||
$bdyear = date("Y");
|
||||
$value = str_replace(["0000", "0001"], $bdyear, $value);
|
||||
$value = str_replace(["0000", "0001"], $bdyear, $value);
|
||||
|
||||
if (strtotime($value) < time()) {
|
||||
$value = str_replace($bdyear, $bdyear + 1, $value);
|
||||
|
@ -1228,10 +1229,10 @@ class DFRN
|
|||
}
|
||||
|
||||
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'], 'about' => $contact['about'],
|
||||
'location' => $contact['location'], 'addr' => $contact['addr'], 'keywords' => $contact['keywords'],
|
||||
'bdyear' => $contact['bdyear'], 'bd' => $contact['bd'], 'hidden' => $contact['hidden'],
|
||||
'xmpp' => $contact['xmpp'], 'name-date' => DateTimeFormat::utc($contact['name-date']),
|
||||
'unsearchable' => $contact['hidden'], 'uri-date' => DateTimeFormat::utc($contact['uri-date'])];
|
||||
'location' => $contact['location'], 'addr' => $contact['addr'], 'keywords' => $contact['keywords'],
|
||||
'bdyear' => $contact['bdyear'], 'bd' => $contact['bd'], 'hidden' => $contact['hidden'],
|
||||
'xmpp' => $contact['xmpp'], 'name-date' => DateTimeFormat::utc($contact['name-date']),
|
||||
'unsearchable' => $contact['hidden'], 'uri-date' => DateTimeFormat::utc($contact['uri-date'])];
|
||||
|
||||
Contact::update($fields, ['id' => $contact['id'], 'network' => $contact['network']], $contact_old);
|
||||
|
||||
|
@ -1267,7 +1268,7 @@ class DFRN
|
|||
return "";
|
||||
}
|
||||
|
||||
$obj_doc = new DOMDocument("1.0", "utf-8");
|
||||
$obj_doc = new DOMDocument("1.0", "utf-8");
|
||||
$obj_doc->formatOutput = true;
|
||||
|
||||
$obj_element = $obj_doc->createElementNS( ActivityNamespace::ATOM1, $element);
|
||||
|
@ -1319,17 +1320,17 @@ class DFRN
|
|||
{
|
||||
DI::logger()->info("Processing mails");
|
||||
|
||||
$msg = [];
|
||||
$msg['uid'] = $importer['importer_uid'];
|
||||
$msg['from-name'] = XML::getFirstValue($xpath, 'dfrn:sender/dfrn:name/text()', $mail);
|
||||
$msg['from-url'] = XML::getFirstValue($xpath, 'dfrn:sender/dfrn:uri/text()', $mail);
|
||||
$msg = [];
|
||||
$msg['uid'] = $importer['importer_uid'];
|
||||
$msg['from-name'] = XML::getFirstValue($xpath, 'dfrn:sender/dfrn:name/text()', $mail);
|
||||
$msg['from-url'] = XML::getFirstValue($xpath, 'dfrn:sender/dfrn:uri/text()', $mail);
|
||||
$msg['from-photo'] = XML::getFirstValue($xpath, 'dfrn:sender/dfrn:avatar/text()', $mail);
|
||||
$msg['contact-id'] = $importer['id'];
|
||||
$msg['uri'] = XML::getFirstValue($xpath, 'dfrn:id/text()', $mail);
|
||||
$msg['uri'] = XML::getFirstValue($xpath, 'dfrn:id/text()', $mail);
|
||||
$msg['parent-uri'] = XML::getFirstValue($xpath, 'dfrn:in-reply-to/text()', $mail);
|
||||
$msg['created'] = DateTimeFormat::utc(XML::getFirstValue($xpath, 'dfrn:sentdate/text()', $mail));
|
||||
$msg['title'] = XML::getFirstValue($xpath, 'dfrn:subject/text()', $mail);
|
||||
$msg['body'] = XML::getFirstValue($xpath, 'dfrn:content/text()', $mail);
|
||||
$msg['created'] = DateTimeFormat::utc(XML::getFirstValue($xpath, 'dfrn:sentdate/text()', $mail));
|
||||
$msg['title'] = XML::getFirstValue($xpath, 'dfrn:subject/text()', $mail);
|
||||
$msg['body'] = XML::getFirstValue($xpath, 'dfrn:content/text()', $mail);
|
||||
|
||||
Mail::insert($msg);
|
||||
}
|
||||
|
@ -1347,8 +1348,8 @@ class DFRN
|
|||
{
|
||||
DI::logger()->info('Processing suggestions');
|
||||
|
||||
$url = $xpath->evaluate('string(dfrn:url[1]/text())', $suggestion);
|
||||
$cid = Contact::getIdForURL($url);
|
||||
$url = $xpath->evaluate('string(dfrn:url[1]/text())', $suggestion);
|
||||
$cid = Contact::getIdForURL($url);
|
||||
$note = $xpath->evaluate('string(dfrn:note[1]/text())', $suggestion);
|
||||
|
||||
return self::addSuggestion($importer['importer_uid'], $cid, $importer['id'], $note);
|
||||
|
@ -1364,8 +1365,8 @@ class DFRN
|
|||
*/
|
||||
private static function addSuggestion(int $uid, int $cid, int $from_cid, string $note = ''): bool
|
||||
{
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
$contact = Contact::getById($cid);
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
$contact = Contact::getById($cid);
|
||||
$from_contact = Contact::getById($from_cid);
|
||||
|
||||
if (DBA::exists('contact', ['nurl' => Strings::normaliseLink($contact['url']), 'uid' => $uid])) {
|
||||
|
@ -1377,15 +1378,15 @@ class DFRN
|
|||
return false;
|
||||
}
|
||||
|
||||
$suggest = [];
|
||||
$suggest['uid'] = $uid;
|
||||
$suggest['cid'] = $from_cid;
|
||||
$suggest['url'] = $contact['url'];
|
||||
$suggest['name'] = $contact['name'];
|
||||
$suggest['photo'] = $contact['photo'];
|
||||
$suggest = [];
|
||||
$suggest['uid'] = $uid;
|
||||
$suggest['cid'] = $from_cid;
|
||||
$suggest['url'] = $contact['url'];
|
||||
$suggest['name'] = $contact['name'];
|
||||
$suggest['photo'] = $contact['photo'];
|
||||
$suggest['request'] = $contact['request'];
|
||||
$suggest['title'] = '';
|
||||
$suggest['body'] = $note;
|
||||
$suggest['title'] = '';
|
||||
$suggest['body'] = $note;
|
||||
|
||||
DI::intro()->save(DI::introFactory()->createNew(
|
||||
$suggest['uid'],
|
||||
|
@ -1424,20 +1425,20 @@ class DFRN
|
|||
DI::logger()->info("Processing relocations");
|
||||
|
||||
/// @TODO Rewrite this to one statement
|
||||
$relocate = [];
|
||||
$relocate['uid'] = $importer['importer_uid'];
|
||||
$relocate['cid'] = $importer['id'];
|
||||
$relocate['url'] = $xpath->query('dfrn:url/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['addr'] = $xpath->query('dfrn:addr/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['name'] = $xpath->query('dfrn:name/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['avatar'] = $xpath->query('dfrn:avatar/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['photo'] = $xpath->query('dfrn:photo/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['thumb'] = $xpath->query('dfrn:thumb/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['micro'] = $xpath->query('dfrn:micro/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['request'] = $xpath->query('dfrn:request/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['confirm'] = $xpath->query('dfrn:confirm/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['notify'] = $xpath->query('dfrn:notify/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['poll'] = $xpath->query('dfrn:poll/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate = [];
|
||||
$relocate['uid'] = $importer['importer_uid'];
|
||||
$relocate['cid'] = $importer['id'];
|
||||
$relocate['url'] = $xpath->query('dfrn:url/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['addr'] = $xpath->query('dfrn:addr/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['name'] = $xpath->query('dfrn:name/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['avatar'] = $xpath->query('dfrn:avatar/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['photo'] = $xpath->query('dfrn:photo/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['thumb'] = $xpath->query('dfrn:thumb/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['micro'] = $xpath->query('dfrn:micro/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['request'] = $xpath->query('dfrn:request/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['confirm'] = $xpath->query('dfrn:confirm/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['notify'] = $xpath->query('dfrn:notify/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['poll'] = $xpath->query('dfrn:poll/text()', $relocation)->item(0)->nodeValue;
|
||||
$relocate['sitepubkey'] = $xpath->query('dfrn:sitepubkey/text()', $relocation)->item(0)->nodeValue;
|
||||
|
||||
if (($relocate['avatar'] == '') && ($relocate['photo'] != '')) {
|
||||
|
@ -1457,15 +1458,15 @@ class DFRN
|
|||
|
||||
// Update the contact table. We try to find every entry.
|
||||
$fields = [
|
||||
'name' => $relocate['name'],
|
||||
'avatar' => $relocate['avatar'],
|
||||
'url' => $relocate['url'],
|
||||
'nurl' => Strings::normaliseLink($relocate['url']),
|
||||
'addr' => $relocate['addr'],
|
||||
'request' => $relocate['request'],
|
||||
'confirm' => $relocate['confirm'],
|
||||
'notify' => $relocate['notify'],
|
||||
'poll' => $relocate['poll'],
|
||||
'name' => $relocate['name'],
|
||||
'avatar' => $relocate['avatar'],
|
||||
'url' => $relocate['url'],
|
||||
'nurl' => Strings::normaliseLink($relocate['url']),
|
||||
'addr' => $relocate['addr'],
|
||||
'request' => $relocate['request'],
|
||||
'confirm' => $relocate['confirm'],
|
||||
'notify' => $relocate['notify'],
|
||||
'poll' => $relocate['poll'],
|
||||
'site-pubkey' => $relocate['sitepubkey'],
|
||||
];
|
||||
$condition = ["(`id` = ?) OR (`nurl` = ?)", $importer['id'], Strings::normaliseLink($old['url'])];
|
||||
|
@ -1506,10 +1507,10 @@ class DFRN
|
|||
}
|
||||
|
||||
$fields = [
|
||||
'title' => $item['title'] ?? '',
|
||||
'body' => $item['body'] ?? '',
|
||||
'title' => $item['title'] ?? '',
|
||||
'body' => $item['body'] ?? '',
|
||||
'changed' => DateTimeFormat::utcNow(),
|
||||
'edited' => DateTimeFormat::utc($item['edited']),
|
||||
'edited' => DateTimeFormat::utc($item['edited']),
|
||||
];
|
||||
|
||||
$condition = ["`uri` = ? AND `uid` IN (0, ?)", $item['uri'], $importer['importer_uid']];
|
||||
|
@ -1611,16 +1612,16 @@ class DFRN
|
|||
}
|
||||
|
||||
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'gravity' => Item::GRAVITY_ACTIVITY,
|
||||
'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
|
||||
'verb' => $item['verb'], 'thr-parent' => $item['thr-parent']];
|
||||
if (Post::exists($condition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The owner of an activity must be the author
|
||||
$item['owner-name'] = $item['author-name'];
|
||||
$item['owner-link'] = $item['author-link'];
|
||||
$item['owner-name'] = $item['author-name'];
|
||||
$item['owner-link'] = $item['author-link'];
|
||||
$item['owner-avatar'] = $item['author-avatar'];
|
||||
$item['owner-id'] = $item['author-id'];
|
||||
$item['owner-id'] = $item['author-id'];
|
||||
}
|
||||
|
||||
if (($item['verb'] == Activity::TAG) && ($item['object-type'] == Activity\ObjectType::TAGTERM)) {
|
||||
|
@ -1654,19 +1655,24 @@ class DFRN
|
|||
*/
|
||||
private static function parseLinks($links, array &$item)
|
||||
{
|
||||
$rel = '';
|
||||
$href = '';
|
||||
$type = null;
|
||||
$rel = '';
|
||||
$href = '';
|
||||
$type = null;
|
||||
$length = null;
|
||||
$title = null;
|
||||
$title = null;
|
||||
foreach ($links as $link) {
|
||||
foreach ($link->attributes as $attributes) {
|
||||
switch ($attributes->name) {
|
||||
case 'href' : $href = $attributes->textContent; break;
|
||||
case 'rel' : $rel = $attributes->textContent; break;
|
||||
case 'type' : $type = $attributes->textContent; break;
|
||||
case 'length': $length = $attributes->textContent; break;
|
||||
case 'title' : $title = $attributes->textContent; break;
|
||||
case 'href': $href = $attributes->textContent;
|
||||
break;
|
||||
case 'rel': $rel = $attributes->textContent;
|
||||
break;
|
||||
case 'type': $type = $attributes->textContent;
|
||||
break;
|
||||
case 'length': $length = $attributes->textContent;
|
||||
break;
|
||||
case 'title': $title = $attributes->textContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (($rel != '') && ($href != '')) {
|
||||
|
@ -1677,7 +1683,7 @@ class DFRN
|
|||
|
||||
case 'enclosure':
|
||||
Post\Media::insert(['uri-id' => $item['uri-id'], 'type' => Post\Media::DOCUMENT,
|
||||
'url' => $href, 'mimetype' => $type, 'size' => $length, 'description' => $title]);
|
||||
'url' => $href, 'mimetype' => $type, 'size' => $length, 'description' => $title]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1745,7 +1751,8 @@ class DFRN
|
|||
|
||||
$item['edited'] = XML::getFirstNodeValue($xpath, 'atom:updated/text()', $entry);
|
||||
|
||||
$current = Post::selectFirst(['id', 'uid', 'edited', 'body'],
|
||||
$current = Post::selectFirst(
|
||||
['id', 'uid', 'edited', 'body'],
|
||||
['uri' => $item['uri'], 'uid' => $importer['importer_uid']]
|
||||
);
|
||||
// Is there an existing item?
|
||||
|
@ -1759,18 +1766,18 @@ class DFRN
|
|||
|
||||
$owner_unknown = (isset($owner['contact-unknown']) && $owner['contact-unknown']);
|
||||
|
||||
$item['owner-name'] = $owner['name'];
|
||||
$item['owner-link'] = $owner['link'];
|
||||
$item['owner-name'] = $owner['name'];
|
||||
$item['owner-link'] = $owner['link'];
|
||||
$item['owner-avatar'] = $owner['avatar'];
|
||||
$item['owner-id'] = Contact::getIdForURL($owner['link'], 0);
|
||||
$item['owner-id'] = Contact::getIdForURL($owner['link'], 0);
|
||||
|
||||
// fetch the author
|
||||
$author = self::fetchauthor($xpath, $entry, $importer, 'atom:author', true, $xml);
|
||||
|
||||
$item['author-name'] = $author['name'];
|
||||
$item['author-link'] = $author['link'];
|
||||
$item['author-name'] = $author['name'];
|
||||
$item['author-link'] = $author['link'];
|
||||
$item['author-avatar'] = $author['avatar'];
|
||||
$item['author-id'] = Contact::getIdForURL($author['link'], 0);
|
||||
$item['author-id'] = Contact::getIdForURL($author['link'], 0);
|
||||
|
||||
$item['title'] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
|
||||
|
||||
|
@ -1794,8 +1801,8 @@ class DFRN
|
|||
// We don't need the content element since "dfrn:env" is always present
|
||||
//$item['body'] = $xpath->query('atom:content/text()', $entry)->item(0)->nodeValue;
|
||||
$item['location'] = XML::getFirstNodeValue($xpath, 'dfrn:location/text()', $entry);
|
||||
$item['coord'] = XML::getFirstNodeValue($xpath, 'georss:point', $entry);
|
||||
$item['private'] = XML::getFirstNodeValue($xpath, 'dfrn:private/text()', $entry);
|
||||
$item['coord'] = XML::getFirstNodeValue($xpath, 'georss:point', $entry);
|
||||
$item['private'] = XML::getFirstNodeValue($xpath, 'dfrn:private/text()', $entry);
|
||||
|
||||
$unlisted = XML::getFirstNodeValue($xpath, 'dfrn:unlisted/text()', $entry);
|
||||
if (!empty($unlisted) && ($item['private'] != Item::PRIVATE)) {
|
||||
|
@ -1845,7 +1852,7 @@ class DFRN
|
|||
$item['object-type'] = XML::getFirstNodeValue($xpath, 'activity:object-type/text()', $entry);
|
||||
}
|
||||
|
||||
$object = $xpath->query('activity:object', $entry)->item(0);
|
||||
$object = $xpath->query('activity:object', $entry)->item(0);
|
||||
$item['object'] = self::transformActivity($xpath, $object, 'object');
|
||||
|
||||
if (trim($item['object']) != '') {
|
||||
|
@ -1855,13 +1862,13 @@ class DFRN
|
|||
}
|
||||
}
|
||||
|
||||
$target = $xpath->query('activity:target', $entry)->item(0);
|
||||
$target = $xpath->query('activity:target', $entry)->item(0);
|
||||
$item['target'] = self::transformActivity($xpath, $target, 'target');
|
||||
|
||||
$categories = $xpath->query('atom:category', $entry);
|
||||
if ($categories) {
|
||||
foreach ($categories as $category) {
|
||||
$term = '';
|
||||
$term = '';
|
||||
$scheme = '';
|
||||
foreach ($category->attributes as $attributes) {
|
||||
if ($attributes->name == 'term') {
|
||||
|
@ -1977,7 +1984,7 @@ class DFRN
|
|||
$ev['source'] = $item['source'];
|
||||
|
||||
$condition = ['uri' => $item['uri'], 'uid' => $importer['importer_uid']];
|
||||
$event = DBA::selectFirst('event', ['id'], $condition);
|
||||
$event = DBA::selectFirst('event', ['id'], $condition);
|
||||
if (DBA::isResult($event)) {
|
||||
$ev['id'] = $event['id'];
|
||||
}
|
||||
|
@ -2054,7 +2061,7 @@ class DFRN
|
|||
|
||||
// This is my contact on another system, but it's really me.
|
||||
// Turn this into a wall post.
|
||||
$notify = Item::isRemoteSelf($importer, $item);
|
||||
$notify = Item::isRemoteSelf($importer, $item);
|
||||
$item['wall'] = (bool)$notify;
|
||||
|
||||
$posted_id = Item::insert($item, $notify);
|
||||
|
@ -2096,7 +2103,7 @@ class DFRN
|
|||
}
|
||||
|
||||
$condition = ['uri' => $uri, 'uid' => $importer['importer_uid']];
|
||||
$item = Post::selectFirst(['id', 'parent', 'contact-id', 'uri-id', 'deleted', 'gravity'], $condition);
|
||||
$item = Post::selectFirst(['id', 'parent', 'contact-id', 'uri-id', 'deleted', 'gravity'], $condition);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::logger()->info('Item with URI ' . $uri . ' for user ' . $importer['importer_uid'] . ' was not found.');
|
||||
return;
|
||||
|
@ -2163,12 +2170,12 @@ class DFRN
|
|||
$xpath->registerNamespace('ostatus', ActivityNamespace::OSTATUS);
|
||||
$xpath->registerNamespace('statusnet', ActivityNamespace::STATUSNET);
|
||||
|
||||
$header = [];
|
||||
$header['uid'] = $importer['importer_uid'];
|
||||
$header['network'] = Protocol::DFRN;
|
||||
$header['protocol'] = $protocol;
|
||||
$header['wall'] = 0;
|
||||
$header['origin'] = 0;
|
||||
$header = [];
|
||||
$header['uid'] = $importer['importer_uid'];
|
||||
$header['network'] = Protocol::DFRN;
|
||||
$header['protocol'] = $protocol;
|
||||
$header['wall'] = 0;
|
||||
$header['origin'] = 0;
|
||||
$header['contact-id'] = $importer['id'];
|
||||
|
||||
$header = Diaspora::setDirection($header, $direction);
|
||||
|
@ -2314,7 +2321,7 @@ class DFRN
|
|||
}
|
||||
|
||||
$existing_edited = DateTimeFormat::utc($existing['edited']);
|
||||
$update_edited = DateTimeFormat::utc($update['edited']);
|
||||
$update_edited = DateTimeFormat::utc($update['edited']);
|
||||
|
||||
return (strcmp($existing_edited, $update_edited) < 0);
|
||||
}
|
||||
|
|
|
@ -185,7 +185,9 @@ class Delivery
|
|||
}
|
||||
|
||||
// We don't deliver our items to blocked, archived or pending contacts, and not to ourselves either
|
||||
$contact = DBA::selectFirst('contact', [],
|
||||
$contact = DBA::selectFirst(
|
||||
'contact',
|
||||
[],
|
||||
['id' => $contact_id, 'archive' => false, 'blocked' => false, 'pending' => false, 'self' => false]
|
||||
);
|
||||
if (!DBA::isResult($contact)) {
|
||||
|
@ -533,10 +535,10 @@ class Delivery
|
|||
|
||||
if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) {
|
||||
if ($reply_to) {
|
||||
$headers = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to . '>' . "\n";
|
||||
$headers = 'From: ' . Email::encodeHeader($local_user['username'], 'UTF-8') . ' <' . $reply_to . '>' . "\n";
|
||||
$headers .= 'Sender: ' . $local_user['email'] . "\n";
|
||||
} else {
|
||||
$headers = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $local_user['email'] . '>' . "\n";
|
||||
$headers = 'From: ' . Email::encodeHeader($local_user['username'], 'UTF-8') . ' <' . $local_user['email'] . '>' . "\n";
|
||||
}
|
||||
} else {
|
||||
$sender = DI::config()->get('config', 'sender_email', 'noreply@' . DI::baseUrl()->getHost());
|
||||
|
|
|
@ -31,7 +31,6 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\Delivery;
|
||||
use Friendica\Util\Crypto;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
|
@ -141,14 +140,14 @@ class Diaspora
|
|||
|
||||
$alg = $children->alg;
|
||||
|
||||
$sig = Strings::base64UrlDecode($children->sig);
|
||||
$sig = Strings::base64UrlDecode($children->sig);
|
||||
$key_id = $children->sig->attributes()->key_id[0];
|
||||
if ($key_id != '') {
|
||||
$handle = Strings::base64UrlDecode($key_id);
|
||||
}
|
||||
|
||||
$b64url_data = Strings::base64UrlEncode($data);
|
||||
$msg = str_replace(["\n", "\r", " ", "\t"], ['', '', '', ''], $b64url_data);
|
||||
$msg = str_replace(["\n", "\r", " ", "\t"], ['', '', '', ''], $b64url_data);
|
||||
|
||||
$signable_data = $msg . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
|
||||
|
||||
|
@ -231,7 +230,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$encrypted_aes_key_bundle = base64_decode($data->aes_key);
|
||||
$ciphertext = base64_decode($data->encrypted_magic_envelope);
|
||||
$ciphertext = base64_decode($data->encrypted_magic_envelope);
|
||||
|
||||
$outer_key_bundle = '';
|
||||
@openssl_private_decrypt($encrypted_aes_key_bundle, $outer_key_bundle, $privKey);
|
||||
|
@ -247,7 +246,7 @@ class Diaspora
|
|||
throw new \RuntimeException('Missing keys "iv" and/or "key" from outer Salmon');
|
||||
}
|
||||
|
||||
$outer_iv = base64_decode($j_outer_key_bundle->iv);
|
||||
$outer_iv = base64_decode($j_outer_key_bundle->iv);
|
||||
$outer_key = base64_decode($j_outer_key_bundle->key);
|
||||
|
||||
$xml = self::aesDecrypt($outer_key, $outer_iv, $ciphertext);
|
||||
|
@ -280,16 +279,16 @@ class Diaspora
|
|||
$data = str_replace([" ", "\t", "\r", "\n"], ['', '', '', ''], $base->data);
|
||||
|
||||
// Build the signed data
|
||||
$type = $base->data[0]->attributes()->type[0];
|
||||
$encoding = $base->encoding;
|
||||
$alg = $base->alg;
|
||||
$type = $base->data[0]->attributes()->type[0];
|
||||
$encoding = $base->encoding;
|
||||
$alg = $base->alg;
|
||||
$signed_data = $data . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
|
||||
|
||||
// This is the signature
|
||||
$signature = Strings::base64UrlDecode($base->sig);
|
||||
|
||||
// Get the senders' public key
|
||||
$key_id = $base->sig[0]->attributes()->key_id[0];
|
||||
$key_id = $base->sig[0]->attributes()->key_id[0];
|
||||
$author_addr = base64_decode($key_id);
|
||||
if ($author_addr == '') {
|
||||
DI::logger()->notice('No author could be decoded. Discarding. Message: ' . $xml);
|
||||
|
@ -302,7 +301,7 @@ class Diaspora
|
|||
|
||||
try {
|
||||
$author = WebFingerUri::fromString($author_addr);
|
||||
$key = self::key($author);
|
||||
$key = self::key($author);
|
||||
if ($key == '') {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
@ -347,7 +346,7 @@ class Diaspora
|
|||
*/
|
||||
public static function decode(string $xml, string $privKey = '')
|
||||
{
|
||||
$public = false;
|
||||
$public = false;
|
||||
$basedom = XML::parseString($xml);
|
||||
|
||||
if (!is_object($basedom)) {
|
||||
|
@ -357,11 +356,11 @@ class Diaspora
|
|||
$children = $basedom->children('https://joindiaspora.com/protocol');
|
||||
|
||||
$inner_aes_key = null;
|
||||
$inner_iv = null;
|
||||
$inner_iv = null;
|
||||
|
||||
if ($children->header) {
|
||||
$public = true;
|
||||
$idom = $children->header;
|
||||
$idom = $children->header;
|
||||
} else {
|
||||
// This happens with posts from a relais
|
||||
if (empty($privKey)) {
|
||||
|
@ -372,14 +371,14 @@ class Diaspora
|
|||
$encrypted_header = json_decode(base64_decode($children->encrypted_header));
|
||||
|
||||
$encrypted_aes_key_bundle = base64_decode($encrypted_header->aes_key);
|
||||
$ciphertext = base64_decode($encrypted_header->ciphertext);
|
||||
$ciphertext = base64_decode($encrypted_header->ciphertext);
|
||||
|
||||
$outer_key_bundle = '';
|
||||
openssl_private_decrypt($encrypted_aes_key_bundle, $outer_key_bundle, $privKey);
|
||||
|
||||
$j_outer_key_bundle = json_decode($outer_key_bundle);
|
||||
|
||||
$outer_iv = base64_decode($j_outer_key_bundle->iv);
|
||||
$outer_iv = base64_decode($j_outer_key_bundle->iv);
|
||||
$outer_key = base64_decode($j_outer_key_bundle->key);
|
||||
|
||||
$decrypted = self::aesDecrypt($outer_key, $outer_iv, $ciphertext);
|
||||
|
@ -387,7 +386,7 @@ class Diaspora
|
|||
DI::logger()->info('decrypted', ['data' => $decrypted]);
|
||||
$idom = XML::parseString($decrypted);
|
||||
|
||||
$inner_iv = base64_decode($idom->iv);
|
||||
$inner_iv = base64_decode($idom->iv);
|
||||
$inner_aes_key = base64_decode($idom->aes_key);
|
||||
}
|
||||
|
||||
|
@ -428,10 +427,10 @@ class Diaspora
|
|||
|
||||
// stash away some other stuff for later
|
||||
|
||||
$type = $base->data[0]->attributes()->type[0];
|
||||
$keyhash = $base->sig[0]->attributes()->keyhash[0];
|
||||
$type = $base->data[0]->attributes()->type[0];
|
||||
$keyhash = $base->sig[0]->attributes()->keyhash[0];
|
||||
$encoding = $base->encoding;
|
||||
$alg = $base->alg;
|
||||
$alg = $base->alg;
|
||||
|
||||
$signed_data = $data . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
|
||||
|
||||
|
@ -496,7 +495,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$importer = [
|
||||
'uid' => 0,
|
||||
'uid' => 0,
|
||||
'page-flags' => User::PAGE_FLAGS_FREELOVE
|
||||
];
|
||||
$success = self::dispatch($importer, $msg, $fields, $direction);
|
||||
|
@ -641,15 +640,16 @@ class Diaspora
|
|||
}
|
||||
}
|
||||
|
||||
$type = $element->getName();
|
||||
$type = $element->getName();
|
||||
$orig_type = $type;
|
||||
|
||||
DI::logger()->debug('Got message', ['type' => $type, 'message' => $msg['message']]);
|
||||
|
||||
// All retractions are handled identically from now on.
|
||||
// In the new version there will only be "retraction".
|
||||
if (in_array($type, ['signed_retraction', 'relayable_retraction']))
|
||||
if (in_array($type, ['signed_retraction', 'relayable_retraction'])) {
|
||||
$type = 'retraction';
|
||||
}
|
||||
|
||||
if ($type == 'request') {
|
||||
$type = 'contact';
|
||||
|
@ -657,8 +657,8 @@ class Diaspora
|
|||
|
||||
$fields = new SimpleXMLElement('<' . $type . '/>');
|
||||
|
||||
$signed_data = '';
|
||||
$author_signature = null;
|
||||
$signed_data = '';
|
||||
$author_signature = null;
|
||||
$parent_author_signature = null;
|
||||
|
||||
foreach ($element->children() as $fieldname => $entry) {
|
||||
|
@ -750,7 +750,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
if (!Crypto::rsaVerify($signed_data, $parent_author_signature, $key, 'sha256')) {
|
||||
DI::logger()->info('No valid parent author signature', ['author' => $msg['author'], 'type' => $type, 'signed data' => $signed_data, 'message' => $msg['message'], 'signature' => $parent_author_signature]);
|
||||
DI::logger()->info('No valid parent author signature', ['author' => $msg['author'], 'type' => $type, 'signed data' => $signed_data, 'message' => $msg['message'], 'signature' => $parent_author_signature]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
if (!Crypto::rsaVerify($signed_data, $author_signature, $key, 'sha256')) {
|
||||
DI::logger()->info('No valid author signature for author', ['author' => $fields->author, 'type' => $type, 'signed data' => $signed_data, 'message' => $msg['message'], 'signature' => $author_signature]);
|
||||
DI::logger()->info('No valid author signature for author', ['author' => $fields->author, 'type' => $type, 'signed data' => $signed_data, 'message' => $msg['message'], 'signature' => $author_signature]);
|
||||
return false;
|
||||
} else {
|
||||
return $fields;
|
||||
|
@ -982,7 +982,7 @@ class Diaspora
|
|||
} else {
|
||||
// No local match, restoring absolute remote URL from author scheme and host
|
||||
$author_url = parse_url($author_link);
|
||||
$return = '[url=' . $author_url['scheme'] . '://' . $author_url['host'] . '/people/' . $match[1] . ']' . $match[2] . '[/url]';
|
||||
$return = '[url=' . $author_url['scheme'] . '://' . $author_url['host'] . '/people/' . $match[1] . ']' . $match[2] . '[/url]';
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -1186,7 +1186,7 @@ class Diaspora
|
|||
];
|
||||
|
||||
$condition = ['uid' => $uid, 'guid' => $guid];
|
||||
$item = Post::selectFirst($fields, $condition);
|
||||
$item = Post::selectFirst($fields, $condition);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
try {
|
||||
|
@ -1231,17 +1231,17 @@ class Diaspora
|
|||
private static function authorContactByUrl(array $def_contact, string $contact_url, int $uid): array
|
||||
{
|
||||
$condition = ['nurl' => Strings::normaliseLink($contact_url), 'uid' => $uid];
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
|
||||
if (DBA::isResult($contact)) {
|
||||
$cid = $contact['id'];
|
||||
$cid = $contact['id'];
|
||||
$network = $contact['network'];
|
||||
} else {
|
||||
$cid = $def_contact['id'];
|
||||
$cid = $def_contact['id'];
|
||||
$network = Protocol::DIASPORA;
|
||||
}
|
||||
|
||||
return [
|
||||
'cid' => $cid,
|
||||
'cid' => $cid,
|
||||
'network' => $network
|
||||
];
|
||||
}
|
||||
|
@ -1283,7 +1283,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$platform = '';
|
||||
$gserver = DBA::selectFirst('gserver', ['platform'], ['nurl' => Strings::normaliseLink($contact['baseurl'])]);
|
||||
$gserver = DBA::selectFirst('gserver', ['platform'], ['nurl' => Strings::normaliseLink($contact['baseurl'])]);
|
||||
if (!empty($gserver['platform'])) {
|
||||
$platform = strtolower($gserver['platform']);
|
||||
DI::logger()->info('Detected platform', ['platform' => $platform, 'url' => $contact['url']]);
|
||||
|
@ -1355,7 +1355,7 @@ class Diaspora
|
|||
|
||||
// Check signature
|
||||
$signed_text = 'AccountMigration:' . $old_author . ':' . $new_author;
|
||||
$key = self::key($old_author);
|
||||
$key = self::key($old_author);
|
||||
if (!Crypto::rsaVerify($signed_text, $signature, $key, 'sha256')) {
|
||||
DI::logger()->notice('No valid signature for migration.');
|
||||
return false;
|
||||
|
@ -1487,10 +1487,10 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveComment(array $importer, WebFingerUri $sender, SimpleXMLElement $data, string $xml, int $direction): bool
|
||||
{
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$parent_guid = XML::unescape($data->parent_guid);
|
||||
$text = XML::unescape($data->text);
|
||||
$text = XML::unescape($data->text);
|
||||
|
||||
if (isset($data->created_at)) {
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
|
@ -1500,7 +1500,7 @@ class Diaspora
|
|||
|
||||
if (isset($data->thread_parent_guid)) {
|
||||
$thread_parent_guid = XML::unescape($data->thread_parent_guid);
|
||||
$thr_parent = self::getUriFromGuid($thread_parent_guid);
|
||||
$thr_parent = self::getUriFromGuid($thread_parent_guid);
|
||||
} else {
|
||||
$thr_parent = '';
|
||||
}
|
||||
|
@ -1536,24 +1536,24 @@ class Diaspora
|
|||
|
||||
$datarray = [];
|
||||
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['contact-id'] = $author_contact['cid'];
|
||||
$datarray['network'] = $author_contact['network'];
|
||||
$datarray['network'] = $author_contact['network'];
|
||||
|
||||
$datarray['author-link'] = $author_url;
|
||||
$datarray['author-id'] = Contact::getIdForURL($author_url);
|
||||
$datarray['author-id'] = Contact::getIdForURL($author_url);
|
||||
|
||||
$datarray['owner-link'] = $contact['url'];
|
||||
$datarray['owner-id'] = Contact::getIdForURL($contact['url']);
|
||||
$datarray['owner-id'] = Contact::getIdForURL($contact['url']);
|
||||
|
||||
// Will be overwritten for sharing accounts in Item::insert
|
||||
$datarray = self::setDirection($datarray, $direction);
|
||||
|
||||
$datarray['guid'] = $guid;
|
||||
$datarray['uri'] = self::getUriFromGuid($guid, $author);
|
||||
$datarray['guid'] = $guid;
|
||||
$datarray['uri'] = self::getUriFromGuid($guid, $author);
|
||||
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
$datarray['private'] = $toplevel_parent_item['private'];
|
||||
|
@ -1565,17 +1565,17 @@ class Diaspora
|
|||
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::COMMENT;
|
||||
$datarray['post-type'] = Item::PT_NOTE;
|
||||
$datarray['post-type'] = Item::PT_NOTE;
|
||||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray['source'] = $xml;
|
||||
$datarray['source'] = $xml;
|
||||
|
||||
$datarray = self::setDirection($datarray, $direction);
|
||||
|
||||
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = $created_at;
|
||||
|
||||
$datarray['plink'] = self::plink($author, $guid, $toplevel_parent_item['guid']);
|
||||
$body = Markdown::toBBCode($text);
|
||||
$body = Markdown::toBBCode($text);
|
||||
|
||||
$datarray['body'] = self::replacePeopleGuid($body, $author_url);
|
||||
|
||||
|
@ -1628,8 +1628,8 @@ class Diaspora
|
|||
private static function receiveConversationMessage(array $importer, array $contact, SimpleXMLElement $data, array $msg, $mesg, array $conversation): bool
|
||||
{
|
||||
$author_handle = XML::unescape($data->author);
|
||||
$guid = XML::unescape($data->guid);
|
||||
$subject = XML::unescape($data->subject);
|
||||
$guid = XML::unescape($data->guid);
|
||||
$subject = XML::unescape($data->subject);
|
||||
|
||||
// "diaspora_handle" is the element name from the old version
|
||||
// "author" is the element name from the new version
|
||||
|
@ -1647,10 +1647,10 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
$msg_guid = XML::unescape($mesg->guid);
|
||||
$msg_guid = XML::unescape($mesg->guid);
|
||||
$msg_conversation_guid = XML::unescape($mesg->conversation_guid);
|
||||
$msg_text = XML::unescape($mesg->text);
|
||||
$msg_created_at = DateTimeFormat::utc(XML::unescape($mesg->created_at));
|
||||
$msg_text = XML::unescape($mesg->text);
|
||||
$msg_created_at = DateTimeFormat::utc(XML::unescape($mesg->created_at));
|
||||
|
||||
if ($msg_conversation_guid != $guid) {
|
||||
DI::logger()->notice('Message conversation guid does not belong to the current conversation.', ['guid' => $guid]);
|
||||
|
@ -1688,10 +1688,10 @@ class Diaspora
|
|||
private static function receiveConversation(array $importer, array $msg, SimpleXMLElement $data)
|
||||
{
|
||||
$author_handle = XML::unescape($data->author);
|
||||
$guid = XML::unescape($data->guid);
|
||||
$subject = XML::unescape($data->subject);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
$participants = XML::unescape($data->participants);
|
||||
$guid = XML::unescape($data->guid);
|
||||
$subject = XML::unescape($data->subject);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
$participants = XML::unescape($data->participants);
|
||||
|
||||
$messages = $data->message;
|
||||
|
||||
|
@ -1751,11 +1751,11 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveLike(array $importer, WebFingerUri $sender, SimpleXMLElement $data, int $direction): bool
|
||||
{
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$parent_guid = XML::unescape($data->parent_guid);
|
||||
$parent_type = XML::unescape($data->parent_type);
|
||||
$positive = XML::unescape($data->positive);
|
||||
$positive = XML::unescape($data->positive);
|
||||
|
||||
// likes on comments aren't supported by Diaspora - only on posts
|
||||
// But maybe this will be supported in the future, so we will accept it.
|
||||
|
@ -1804,19 +1804,19 @@ class Diaspora
|
|||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['contact-id'] = $author_contact['cid'];
|
||||
$datarray['network'] = $author_contact['network'];
|
||||
$datarray['network'] = $author_contact['network'];
|
||||
|
||||
$datarray = self::setDirection($datarray, $direction);
|
||||
|
||||
$datarray['owner-link'] = $datarray['author-link'] = $author_url;
|
||||
$datarray['owner-id'] = $datarray['author-id'] = Contact::getIdForURL($author_url);
|
||||
$datarray['owner-id'] = $datarray['author-id'] = Contact::getIdForURL($author_url);
|
||||
|
||||
$datarray['guid'] = $guid;
|
||||
$datarray['uri'] = self::getUriFromGuid($guid, $author);
|
||||
$datarray['uri'] = self::getUriFromGuid($guid, $author);
|
||||
|
||||
$datarray['verb'] = $verb;
|
||||
$datarray['verb'] = $verb;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
|
||||
$datarray['private'] = $toplevel_parent_item['private'];
|
||||
|
@ -1837,7 +1837,7 @@ class Diaspora
|
|||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
if ($toplevel_parent_item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
$toplevel = Post::selectFirst(['origin'], ['id' => $toplevel_parent_item['parent']]);
|
||||
$origin = $toplevel['origin'];
|
||||
$origin = $toplevel['origin'];
|
||||
} else {
|
||||
$origin = $toplevel_parent_item['origin'];
|
||||
}
|
||||
|
@ -1880,11 +1880,11 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveMessage(array $importer, SimpleXMLElement $data): bool
|
||||
{
|
||||
$author_uri = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$author_uri = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$conversation_guid = XML::unescape($data->conversation_guid);
|
||||
$text = XML::unescape($data->text);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
$text = XML::unescape($data->text);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
|
||||
$contact = self::allowedContactByHandle($importer, $author_uri, true);
|
||||
if (!$contact) {
|
||||
|
@ -1895,7 +1895,7 @@ class Diaspora
|
|||
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
|
||||
}
|
||||
|
||||
$condition = ['uid' => $importer['uid'], 'guid' => $conversation_guid];
|
||||
$condition = ['uid' => $importer['uid'], 'guid' => $conversation_guid];
|
||||
$conversation = DBA::selectFirst('conv', [], $condition);
|
||||
if (!DBA::isResult($conversation)) {
|
||||
DI::logger()->notice('Conversation not available.');
|
||||
|
@ -1943,8 +1943,8 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveParticipation(array $importer, SimpleXMLElement $data, int $direction): bool
|
||||
{
|
||||
$author = WebFingerUri::fromString(strtolower(XML::unescape($data->author)));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$author = WebFingerUri::fromString(strtolower(XML::unescape($data->author)));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$parent_guid = XML::unescape($data->parent_guid);
|
||||
|
||||
$contact = self::allowedContactByHandle($importer, $author, true);
|
||||
|
@ -1988,20 +1988,20 @@ class Diaspora
|
|||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['contact-id'] = $author_contact['cid'];
|
||||
$datarray['network'] = $author_contact['network'];
|
||||
$datarray['network'] = $author_contact['network'];
|
||||
|
||||
$datarray = self::setDirection($datarray, $direction);
|
||||
|
||||
$datarray['owner-link'] = $datarray['author-link'] = $author_url;
|
||||
$datarray['owner-id'] = $datarray['author-id'] = Contact::getIdForURL($author_url);
|
||||
$datarray['owner-id'] = $datarray['author-id'] = Contact::getIdForURL($author_url);
|
||||
|
||||
$datarray['guid'] = $guid;
|
||||
$datarray['uri'] = self::getUriFromGuid($guid, $author);
|
||||
$datarray['uri'] = self::getUriFromGuid($guid, $author);
|
||||
|
||||
$datarray['verb'] = Activity::FOLLOW;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['verb'] = Activity::FOLLOW;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
@ -2099,14 +2099,14 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
$name = XML::unescape($data->first_name) . ((strlen($data->last_name)) ? ' ' . XML::unescape($data->last_name) : '');
|
||||
$image_url = XML::unescape($data->image_url);
|
||||
$birthday = XML::unescape($data->birthday);
|
||||
$about = Markdown::toBBCode(XML::unescape($data->bio));
|
||||
$location = Markdown::toBBCode(XML::unescape($data->location));
|
||||
$name = XML::unescape($data->first_name) . ((strlen($data->last_name)) ? ' ' . XML::unescape($data->last_name) : '');
|
||||
$image_url = XML::unescape($data->image_url);
|
||||
$birthday = XML::unescape($data->birthday);
|
||||
$about = Markdown::toBBCode(XML::unescape($data->bio));
|
||||
$location = Markdown::toBBCode(XML::unescape($data->location));
|
||||
$searchable = (XML::unescape($data->searchable) == 'true');
|
||||
$nsfw = (XML::unescape($data->nsfw) == 'true');
|
||||
$tags = XML::unescape($data->tag_string);
|
||||
$nsfw = (XML::unescape($data->nsfw) == 'true');
|
||||
$tags = XML::unescape($data->tag_string);
|
||||
|
||||
$tags = explode('#', $tags);
|
||||
|
||||
|
@ -2147,9 +2147,9 @@ class Diaspora
|
|||
}
|
||||
|
||||
$fields = [
|
||||
'name' => $name, 'location' => $location,
|
||||
'name-date' => DateTimeFormat::utcNow(), 'about' => $about,
|
||||
'addr' => $author->getAddr(), 'nick' => $author->getUser(), 'keywords' => $keywords,
|
||||
'name' => $name, 'location' => $location,
|
||||
'name-date' => DateTimeFormat::utcNow(), 'about' => $about,
|
||||
'addr' => $author->getAddr(), 'nick' => $author->getUser(), 'keywords' => $keywords,
|
||||
'unsearchable' => !$searchable, 'sensitive' => $nsfw
|
||||
];
|
||||
|
||||
|
@ -2194,7 +2194,7 @@ class Diaspora
|
|||
private static function receiveContactRequest(array $importer, SimpleXMLElement $data): bool
|
||||
{
|
||||
$author_handle = XML::unescape($data->author);
|
||||
$recipient = XML::unescape($data->recipient);
|
||||
$recipient = XML::unescape($data->recipient);
|
||||
|
||||
if (!$author_handle || !$recipient) {
|
||||
return false;
|
||||
|
@ -2312,8 +2312,8 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveReshare(array $importer, SimpleXMLElement $data, string $xml, int $direction): bool
|
||||
{
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
try {
|
||||
$root_author = WebFingerUri::fromString(XML::unescape($data->root_author));
|
||||
|
@ -2347,25 +2347,25 @@ class Diaspora
|
|||
|
||||
$datarray = [];
|
||||
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['uid'] = $importer['uid'];
|
||||
$datarray['contact-id'] = $contact['id'];
|
||||
$datarray['network'] = Protocol::DIASPORA;
|
||||
$datarray['network'] = Protocol::DIASPORA;
|
||||
|
||||
$datarray['author-link'] = $contact['url'];
|
||||
$datarray['author-id'] = Contact::getIdForURL($contact['url'], 0);
|
||||
$datarray['author-id'] = Contact::getIdForURL($contact['url'], 0);
|
||||
|
||||
$datarray['owner-link'] = $datarray['author-link'];
|
||||
$datarray['owner-id'] = $datarray['author-id'];
|
||||
$datarray['owner-id'] = $datarray['author-id'];
|
||||
|
||||
$datarray['guid'] = $guid;
|
||||
$datarray['uri'] = $datarray['thr-parent'] = self::getUriFromGuid($guid, $author);
|
||||
$datarray['guid'] = $guid;
|
||||
$datarray['uri'] = $datarray['thr-parent'] = self::getUriFromGuid($guid, $author);
|
||||
$datarray['uri-id'] = ItemURI::insert(['uri' => $datarray['uri'], 'guid' => $datarray['guid']]);
|
||||
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = Item::GRAVITY_PARENT;
|
||||
|
||||
$datarray['protocol'] = Conversation::PARCEL_DIASPORA;
|
||||
$datarray['source'] = $xml;
|
||||
$datarray['source'] = $xml;
|
||||
|
||||
$datarray = self::setDirection($datarray, $direction);
|
||||
|
||||
|
@ -2624,11 +2624,11 @@ class Diaspora
|
|||
*/
|
||||
private static function receiveStatusMessage(array $importer, SimpleXMLElement $data, string $xml, int $direction)
|
||||
{
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
$public = XML::unescape($data->public);
|
||||
$text = XML::unescape($data->text);
|
||||
$author = WebFingerUri::fromString(XML::unescape($data->author));
|
||||
$guid = XML::unescape($data->guid);
|
||||
$created_at = DateTimeFormat::utc(XML::unescape($data->created_at));
|
||||
$public = XML::unescape($data->public);
|
||||
$text = XML::unescape($data->text);
|
||||
$provider_display_name = XML::unescape($data->provider_display_name);
|
||||
|
||||
$contact = self::allowedContactByHandle($importer, $author);
|
||||
|
@ -2688,7 +2688,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::IMAGE;
|
||||
$datarray['post-type'] = Item::PT_IMAGE;
|
||||
$datarray['post-type'] = Item::PT_IMAGE;
|
||||
} elseif ($data->poll) {
|
||||
$datarray['post-type'] = Item::PT_POLL;
|
||||
}
|
||||
|
@ -2798,10 +2798,10 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
$aes_key = random_bytes(32);
|
||||
$aes_key = random_bytes(32);
|
||||
$b_aes_key = base64_encode($aes_key);
|
||||
$iv = random_bytes(16);
|
||||
$b_iv = base64_encode($iv);
|
||||
$iv = random_bytes(16);
|
||||
$b_iv = base64_encode($iv);
|
||||
|
||||
$ciphertext = self::aesEncrypt($aes_key, $iv, $msg);
|
||||
|
||||
|
@ -2814,7 +2814,7 @@ class Diaspora
|
|||
|
||||
$json_object = json_encode(
|
||||
[
|
||||
'aes_key' => base64_encode($encrypted_key_bundle),
|
||||
'aes_key' => base64_encode($encrypted_key_bundle),
|
||||
'encrypted_magic_envelope' => base64_encode($ciphertext)
|
||||
]
|
||||
);
|
||||
|
@ -2834,12 +2834,12 @@ class Diaspora
|
|||
public static function buildMagicEnvelope(string $msg, array $user): string
|
||||
{
|
||||
$b64url_data = Strings::base64UrlEncode($msg);
|
||||
$data = str_replace(["\n", "\r", ' ', "\t"], ['', '', '', ''], $b64url_data);
|
||||
$data = str_replace(["\n", "\r", ' ', "\t"], ['', '', '', ''], $b64url_data);
|
||||
|
||||
$key_id = Strings::base64UrlEncode(self::myHandle($user));
|
||||
$type = 'application/xml';
|
||||
$encoding = 'base64url';
|
||||
$alg = 'RSA-SHA256';
|
||||
$key_id = Strings::base64UrlEncode(self::myHandle($user));
|
||||
$type = 'application/xml';
|
||||
$encoding = 'base64url';
|
||||
$alg = 'RSA-SHA256';
|
||||
$signable_data = $data . '.' . Strings::base64UrlEncode($type) . '.' . Strings::base64UrlEncode($encoding) . '.' . Strings::base64UrlEncode($alg);
|
||||
|
||||
// Fallback if the private key wasn't transmitted in the expected field
|
||||
|
@ -2848,7 +2848,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$signature = Crypto::rsaSign($signable_data, $user['uprvkey']);
|
||||
$sig = Strings::base64UrlEncode($signature);
|
||||
$sig = Strings::base64UrlEncode($signature);
|
||||
|
||||
$xmldata = [
|
||||
'me:env' => [
|
||||
|
@ -2935,7 +2935,7 @@ class Diaspora
|
|||
// We always try to use the data from the diaspora-contact table.
|
||||
// This is important for transmitting data to Friendica servers.
|
||||
try {
|
||||
$target = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']));
|
||||
$target = DI::dsprContact()->getByAddr(WebFingerUri::fromString($contact['addr']));
|
||||
$dest_url = $public_batch ? $target->batch : $target->notify;
|
||||
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
|
||||
}
|
||||
|
@ -3069,9 +3069,9 @@ class Diaspora
|
|||
// If the item belongs to a user, we take this user id.
|
||||
if ($item['uid'] == 0) {
|
||||
// @todo Possibly use an administrator account?
|
||||
$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON];
|
||||
$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON];
|
||||
$first_user = DBA::selectFirst('user', ['uid'], $condition, ['order' => ['uid']]);
|
||||
$owner = User::getOwnerDataById($first_user['uid']);
|
||||
$owner = User::getOwnerDataById($first_user['uid']);
|
||||
} else {
|
||||
$owner = User::getOwnerDataById($item['uid']);
|
||||
}
|
||||
|
@ -3079,8 +3079,8 @@ class Diaspora
|
|||
$author_handle = self::myHandle($owner);
|
||||
|
||||
$message = [
|
||||
'author' => $author_handle,
|
||||
'guid' => System::createUUID(),
|
||||
'author' => $author_handle,
|
||||
'guid' => System::createUUID(),
|
||||
'parent_type' => 'Post',
|
||||
'parent_guid' => $item['guid']
|
||||
];
|
||||
|
@ -3107,14 +3107,14 @@ class Diaspora
|
|||
public static function sendAccountMigration(array $owner, array $contact, int $uid): int
|
||||
{
|
||||
$old_handle = DI::pConfig()->get($uid, 'system', 'previous_addr');
|
||||
$profile = self::createProfileData($uid);
|
||||
$profile = self::createProfileData($uid);
|
||||
|
||||
$signed_text = 'AccountMigration:' . $old_handle . ':' . $profile['author'];
|
||||
$signature = base64_encode(Crypto::rsaSign($signed_text, $owner['uprvkey'], 'sha256'));
|
||||
$signature = base64_encode(Crypto::rsaSign($signed_text, $owner['uprvkey'], 'sha256'));
|
||||
|
||||
$message = [
|
||||
'author' => $old_handle,
|
||||
'profile' => $profile,
|
||||
'author' => $old_handle,
|
||||
'profile' => $profile,
|
||||
'signature' => $signature
|
||||
];
|
||||
|
||||
|
@ -3158,10 +3158,10 @@ class Diaspora
|
|||
*/
|
||||
|
||||
$message = [
|
||||
'author' => self::myHandle($owner),
|
||||
'author' => self::myHandle($owner),
|
||||
'recipient' => $contact['addr'],
|
||||
'following' => 'true',
|
||||
'sharing' => 'true'
|
||||
'sharing' => 'true'
|
||||
];
|
||||
|
||||
DI::logger()->info('Send share', ['msg' => $message]);
|
||||
|
@ -3270,9 +3270,9 @@ class Diaspora
|
|||
}
|
||||
if ($event['location']) {
|
||||
$event['location'] = preg_replace("/\[map\](.*?)\[\/map\]/ism", '$1', $event['location']);
|
||||
$coord = Map::getCoordinates($event['location']);
|
||||
$coord = Map::getCoordinates($event['location']);
|
||||
|
||||
$location = [];
|
||||
$location = [];
|
||||
$location['address'] = html_entity_decode(BBCode::toMarkdown($event['location']));
|
||||
if (!empty($coord['lat']) && !empty($coord['lon'])) {
|
||||
$location['lat'] = $coord['lat'];
|
||||
|
@ -3310,9 +3310,9 @@ class Diaspora
|
|||
|
||||
$myaddr = self::myHandle($owner);
|
||||
|
||||
$public = ($item['private'] == Item::PRIVATE ? 'false' : 'true');
|
||||
$public = ($item['private'] == Item::PRIVATE ? 'false' : 'true');
|
||||
$created = DateTimeFormat::utc($item['received'], DateTimeFormat::ATOM);
|
||||
$edited = DateTimeFormat::utc($item['edited'] ?? $item['created'], DateTimeFormat::ATOM);
|
||||
$edited = DateTimeFormat::utc($item['edited'] ?? $item['created'], DateTimeFormat::ATOM);
|
||||
|
||||
// Detect a share element and do a reshare
|
||||
if (($item['private'] != Item::PRIVATE) && ($ret = self::getReshareDetails($item))) {
|
||||
|
@ -3366,24 +3366,25 @@ class Diaspora
|
|||
|
||||
$location = [];
|
||||
|
||||
if ($item['location'] != '')
|
||||
if ($item['location'] != '') {
|
||||
$location['address'] = $item['location'];
|
||||
}
|
||||
|
||||
if ($item['coord'] != '') {
|
||||
$coord = explode(' ', $item['coord']);
|
||||
$coord = explode(' ', $item['coord']);
|
||||
$location['lat'] = $coord[0];
|
||||
$location['lng'] = $coord[1];
|
||||
}
|
||||
|
||||
$message = [
|
||||
'author' => $myaddr,
|
||||
'guid' => $item['guid'],
|
||||
'created_at' => $created,
|
||||
'edited_at' => $edited,
|
||||
'public' => $public,
|
||||
'text' => $body,
|
||||
'author' => $myaddr,
|
||||
'guid' => $item['guid'],
|
||||
'created_at' => $created,
|
||||
'edited_at' => $edited,
|
||||
'public' => $public,
|
||||
'text' => $body,
|
||||
'provider_display_name' => $item['app'],
|
||||
'location' => $location
|
||||
'location' => $location
|
||||
];
|
||||
|
||||
if ($native_photos) {
|
||||
|
@ -3514,7 +3515,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$target_type = ($parent['uri'] === $parent['thr-parent'] ? 'Post' : 'Comment');
|
||||
$positive = null;
|
||||
$positive = null;
|
||||
if ($item['verb'] === Activity::LIKE) {
|
||||
$positive = 'true';
|
||||
} elseif ($item['verb'] === Activity::DISLIKE) {
|
||||
|
@ -3563,10 +3564,10 @@ class Diaspora
|
|||
}
|
||||
|
||||
return [
|
||||
'author' => self::myHandle($owner),
|
||||
'guid' => $item['guid'],
|
||||
'parent_guid' => $parent['guid'],
|
||||
'status' => $attend_answer,
|
||||
'author' => self::myHandle($owner),
|
||||
'guid' => $item['guid'],
|
||||
'parent_guid' => $parent['guid'],
|
||||
'status' => $attend_answer,
|
||||
'author_signature' => ''
|
||||
];
|
||||
}
|
||||
|
@ -3616,17 +3617,17 @@ class Diaspora
|
|||
$body = self::prependParentAuthorMention($body, $thread_parent_item['author-link']);
|
||||
}
|
||||
|
||||
$text = html_entity_decode(BBCode::toMarkdown($body));
|
||||
$text = html_entity_decode(BBCode::toMarkdown($body));
|
||||
$created = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
|
||||
$edited = DateTimeFormat::utc($item['edited'], DateTimeFormat::ATOM);
|
||||
$edited = DateTimeFormat::utc($item['edited'], DateTimeFormat::ATOM);
|
||||
|
||||
$comment = [
|
||||
'author' => self::myHandle($owner),
|
||||
'guid' => $item['guid'],
|
||||
'created_at' => $created,
|
||||
'edited_at' => $edited,
|
||||
'parent_guid' => $toplevel_item['guid'],
|
||||
'text' => $text,
|
||||
'author' => self::myHandle($owner),
|
||||
'guid' => $item['guid'],
|
||||
'created_at' => $created,
|
||||
'edited_at' => $edited,
|
||||
'parent_guid' => $toplevel_item['guid'],
|
||||
'text' => $text,
|
||||
'author_signature' => '',
|
||||
];
|
||||
|
||||
|
@ -3658,13 +3659,13 @@ class Diaspora
|
|||
|
||||
if (in_array($item['verb'], [Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE])) {
|
||||
$message = self::constructAttend($item, $owner);
|
||||
$type = 'event_participation';
|
||||
$type = 'event_participation';
|
||||
} elseif (in_array($item['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
$message = self::constructLike($item, $owner);
|
||||
$type = 'like';
|
||||
$type = 'like';
|
||||
} elseif (!in_array($item['verb'], [Activity::FOLLOW, Activity::TAG])) {
|
||||
$message = self::constructComment($item, $owner);
|
||||
$type = 'comment';
|
||||
$type = 'comment';
|
||||
}
|
||||
|
||||
if (empty($message)) {
|
||||
|
@ -3753,7 +3754,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
$message = [
|
||||
'author' => $itemaddr,
|
||||
'author' => $itemaddr,
|
||||
'target_guid' => $item['guid'],
|
||||
'target_type' => $target_type
|
||||
];
|
||||
|
@ -3784,28 +3785,28 @@ class Diaspora
|
|||
return -1;
|
||||
}
|
||||
|
||||
$body = BBCode::toMarkdown($item['body']);
|
||||
$body = BBCode::toMarkdown($item['body']);
|
||||
$created = DateTimeFormat::utc($item['created'], DateTimeFormat::ATOM);
|
||||
|
||||
$msg = [
|
||||
'author' => $myaddr,
|
||||
'guid' => $item['guid'],
|
||||
'author' => $myaddr,
|
||||
'guid' => $item['guid'],
|
||||
'conversation_guid' => $cnv['guid'],
|
||||
'text' => $body,
|
||||
'created_at' => $created,
|
||||
'text' => $body,
|
||||
'created_at' => $created,
|
||||
];
|
||||
|
||||
if ($item['reply']) {
|
||||
$message = $msg;
|
||||
$type = 'message';
|
||||
$type = 'message';
|
||||
} else {
|
||||
$message = [
|
||||
'author' => $cnv['creator'],
|
||||
'guid' => $cnv['guid'],
|
||||
'subject' => $cnv['subject'],
|
||||
'created_at' => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
'author' => $cnv['creator'],
|
||||
'guid' => $cnv['guid'],
|
||||
'subject' => $cnv['subject'],
|
||||
'created_at' => DateTimeFormat::utc($cnv['created'], DateTimeFormat::ATOM),
|
||||
'participants' => $cnv['recips'],
|
||||
'message' => $msg
|
||||
'message' => $msg
|
||||
];
|
||||
|
||||
$type = 'conversation';
|
||||
|
@ -3836,14 +3837,14 @@ class Diaspora
|
|||
|
||||
// Take the first word as first name
|
||||
$first = ((strpos($name, ' ') ? trim(substr($name, 0, strpos($name, ' '))) : $name));
|
||||
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
|
||||
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
|
||||
if ((strlen($first) < 32) && (strlen($last) < 32)) {
|
||||
return ['first' => $first, 'last' => $last];
|
||||
}
|
||||
|
||||
// Take the last word as last name
|
||||
$first = ((strrpos($name, ' ') ? trim(substr($name, 0, strrpos($name, ' '))) : $name));
|
||||
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
|
||||
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
|
||||
|
||||
if ((strlen($first) < 32) && (strlen($last) < 32)) {
|
||||
return ['first' => $first, 'last' => $last];
|
||||
|
@ -3852,12 +3853,12 @@ class Diaspora
|
|||
// Take the first 32 characters if there is no space in the first 32 characters
|
||||
if ((strpos($name, ' ') > 32) || (strpos($name, ' ') === false)) {
|
||||
$first = substr($name, 0, 32);
|
||||
$last = substr($name, 32);
|
||||
$last = substr($name, 32);
|
||||
return ['first' => $first, 'last' => $last];
|
||||
}
|
||||
|
||||
$first = trim(substr($name, 0, strrpos(substr($name, 0, 33), ' ')));
|
||||
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
|
||||
$last = (($first === $name) ? '' : trim(substr($name, strlen($first))));
|
||||
|
||||
// Check if the last name is longer than 32 characters
|
||||
if (strlen($last) > 32) {
|
||||
|
@ -3912,7 +3913,7 @@ class Diaspora
|
|||
$data['birthday'] = '';
|
||||
|
||||
if ($profile['dob'] && ($profile['dob'] > '0000-00-00')) {
|
||||
[$year, $month, $day] = sscanf($profile['dob'], '%4d-%2d-%2d');
|
||||
list($year, $month, $day) = sscanf($profile['dob'], '%4d-%2d-%2d');
|
||||
if ($year < 1004) {
|
||||
$year = 1004;
|
||||
}
|
||||
|
@ -3921,12 +3922,12 @@ class Diaspora
|
|||
|
||||
$data['bio'] = BBCode::toMarkdown($profile['about'] ?? '');
|
||||
|
||||
$data['location'] = $profile['location'];
|
||||
$data['location'] = $profile['location'];
|
||||
$data['tag_string'] = '';
|
||||
|
||||
if ($profile['pub_keywords']) {
|
||||
$kw = str_replace(',', ' ', $profile['pub_keywords']);
|
||||
$kw = str_replace(' ', ' ', $kw);
|
||||
$kw = str_replace(',', ' ', $profile['pub_keywords']);
|
||||
$kw = str_replace(' ', ' ', $kw);
|
||||
$arr = explode(' ', $kw);
|
||||
if (count($arr)) {
|
||||
for ($x = 0; $x < 5; $x++) {
|
||||
|
@ -4003,7 +4004,8 @@ class Diaspora
|
|||
}
|
||||
|
||||
if (!in_array($item['verb'], [Activity::LIKE, Activity::DISLIKE])) {
|
||||
DI::logger()->warning('Item is neither a like nor a dislike', ['uid' => $uid, 'item[verb]' => $item['verb']]);;
|
||||
DI::logger()->warning('Item is neither a like nor a dislike', ['uid' => $uid, 'item[verb]' => $item['verb']]);
|
||||
;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4120,8 +4122,8 @@ class Diaspora
|
|||
'quote-uri-id' => $UriId,
|
||||
'allow_cid' => $owner['allow_cid'] ?? '',
|
||||
'allow_gid' => $owner['allow_gid'] ?? '',
|
||||
'deny_cid' => $owner['deny_cid'] ?? '',
|
||||
'deny_gid' => $owner['deny_gid'] ?? '',
|
||||
'deny_cid' => $owner['deny_cid'] ?? '',
|
||||
'deny_gid' => $owner['deny_gid'] ?? '',
|
||||
];
|
||||
|
||||
if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) {
|
||||
|
|
|
@ -127,7 +127,7 @@ class Email
|
|||
*/
|
||||
public static function getMessage($mbox, int $uid, string $reply, array $item): array
|
||||
{
|
||||
$ret = $item;
|
||||
$ret = $item;
|
||||
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox, $uid, FT_UID) : null);
|
||||
|
||||
if (!$struc) {
|
||||
|
@ -154,7 +154,7 @@ class Email
|
|||
|
||||
$message = ['text' => $text, 'html' => '', 'item' => $ret];
|
||||
Hook::callAll('email_getmessage', $message);
|
||||
$ret = $message['item'];
|
||||
$ret = $message['item'];
|
||||
$ret['body'] = $message['text'];
|
||||
}
|
||||
} else {
|
||||
|
@ -186,7 +186,7 @@ class Email
|
|||
}
|
||||
|
||||
$ret['body'] = self::removeGPG($ret['body']);
|
||||
$msg = self::removeSig($ret['body']);
|
||||
$msg = self::removeSig($ret['body']);
|
||||
$ret['body'] = $msg['body'];
|
||||
$ret['body'] = self::convertQuote($ret['body'], $reply);
|
||||
|
||||
|
@ -221,8 +221,8 @@ class Email
|
|||
|
||||
// DECODE DATA
|
||||
$data = ($partno)
|
||||
? @imap_fetchbody($mbox, $uid, $partno, FT_UID|FT_PEEK)
|
||||
: @imap_body($mbox, $uid, FT_UID|FT_PEEK);
|
||||
? @imap_fetchbody($mbox, $uid, $partno, FT_UID | FT_PEEK)
|
||||
: @imap_body($mbox, $uid, FT_UID | FT_PEEK);
|
||||
|
||||
// Any part may be encoded, even plain text messages, so check everything.
|
||||
if ($p->encoding == 4) {
|
||||
|
@ -261,7 +261,7 @@ class Email
|
|||
if ($p->type == 0 && $data) {
|
||||
// Messages may be split in different parts because of inline attachments,
|
||||
// so append parts together with blank row.
|
||||
if (strtolower($p->subtype)==$subtype) {
|
||||
if (strtolower($p->subtype) == $subtype) {
|
||||
$data = iconv($params['charset'], 'UTF-8//IGNORE', $data);
|
||||
return (trim($data) ."\n\n");
|
||||
} else {
|
||||
|
@ -285,7 +285,7 @@ class Email
|
|||
if (isset($p->parts) && $p->parts) {
|
||||
$x = "";
|
||||
foreach ($p->parts as $partno0 => $p2) {
|
||||
$x .= self::messageGetPart($mbox, $uid, $p2, $partno . '.' . ($partno0+1), $subtype); // 1.2, 1.2.1, etc.
|
||||
$x .= self::messageGetPart($mbox, $uid, $p2, $partno . '.' . ($partno0 + 1), $subtype); // 1.2, 1.2.1, etc.
|
||||
}
|
||||
return $x;
|
||||
}
|
||||
|
@ -301,10 +301,10 @@ class Email
|
|||
*/
|
||||
public static function encodeHeader(string $in_str, string $charset): string
|
||||
{
|
||||
$out_str = $in_str;
|
||||
$out_str = $in_str;
|
||||
$need_to_convert = false;
|
||||
|
||||
for ($x = 0; $x < strlen($in_str); $x ++) {
|
||||
for ($x = 0; $x < strlen($in_str); $x++) {
|
||||
if ((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) {
|
||||
$need_to_convert = true;
|
||||
}
|
||||
|
@ -316,8 +316,8 @@ class Email
|
|||
|
||||
if ($out_str && $charset) {
|
||||
// define start delimiter, end delimiter and spacer
|
||||
$end = "?=";
|
||||
$start = "=?" . $charset . "?B?";
|
||||
$end = "?=";
|
||||
$start = "=?" . $charset . "?B?";
|
||||
$spacer = $end . "\r\n " . $start;
|
||||
|
||||
// determine length of encoded text within chunks
|
||||
|
@ -344,7 +344,7 @@ class Email
|
|||
|
||||
// remove trailing spacer and
|
||||
// add start and end delimiters
|
||||
$spacer = preg_quote($spacer, '/');
|
||||
$spacer = preg_quote($spacer, '/');
|
||||
$out_str = preg_replace("/" . $spacer . "$/", "", $out_str);
|
||||
$out_str = $start . $out_str . $end;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ class Email
|
|||
|
||||
$part = uniqid('', true);
|
||||
|
||||
$html = Item::prepareBody($item);
|
||||
$html = Item::prepareBody($item);
|
||||
|
||||
$headers .= "Mime-Version: 1.0\n";
|
||||
$headers .= 'Content-Type: multipart/alternative; boundary="=_'.$part.'"'."\n\n";
|
||||
|
@ -571,13 +571,13 @@ class Email
|
|||
*/
|
||||
private static function removeSig(string $message): array
|
||||
{
|
||||
$sigpos = strrpos($message, "\n-- \n");
|
||||
$sigpos = strrpos($message, "\n-- \n");
|
||||
$quotepos = strrpos($message, "[/quote]");
|
||||
|
||||
if ($sigpos == 0) {
|
||||
// Especially for web.de who are using that as a separator
|
||||
$message = str_replace("\n___________________________________________________________\n", "\n-- \n", $message);
|
||||
$sigpos = strrpos($message, "\n-- \n");
|
||||
$message = str_replace("\n___________________________________________________________\n", "\n-- \n", $message);
|
||||
$sigpos = strrpos($message, "\n-- \n");
|
||||
$quotepos = strrpos($message, "[/quote]");
|
||||
}
|
||||
|
||||
|
@ -592,10 +592,10 @@ class Email
|
|||
|
||||
if (!empty($result[1]) && !empty($result[2])) {
|
||||
$cleaned = trim($result[1])."\n";
|
||||
$sig = trim($result[2]);
|
||||
$sig = trim($result[2]);
|
||||
} else {
|
||||
$cleaned = $message;
|
||||
$sig = '';
|
||||
$sig = '';
|
||||
}
|
||||
|
||||
return ['body' => $cleaned, 'sig' => $sig];
|
||||
|
@ -611,13 +611,13 @@ class Email
|
|||
{
|
||||
$arrbody = explode("\n", trim($message));
|
||||
|
||||
$lines = [];
|
||||
$lines = [];
|
||||
$lineno = 0;
|
||||
|
||||
foreach ($arrbody as $i => $line) {
|
||||
$currquotelevel = 0;
|
||||
$currline = $line;
|
||||
while ((strlen($currline)>0) && ((substr($currline, 0, 1) == '>')
|
||||
$currline = $line;
|
||||
while ((strlen($currline) > 0) && ((substr($currline, 0, 1) == '>')
|
||||
|| (substr($currline, 0, 1) == ' '))) {
|
||||
if (substr($currline, 0, 1) == '>') {
|
||||
$currquotelevel++;
|
||||
|
@ -627,8 +627,8 @@ class Email
|
|||
}
|
||||
|
||||
$quotelevel = 0;
|
||||
$nextline = trim($arrbody[$i + 1] ?? '');
|
||||
while ((strlen($nextline)>0) && ((substr($nextline, 0, 1) == '>')
|
||||
$nextline = trim($arrbody[$i + 1] ?? '');
|
||||
while ((strlen($nextline) > 0) && ((substr($nextline, 0, 1) == '>')
|
||||
|| (substr($nextline, 0, 1) == ' '))) {
|
||||
if (substr($nextline, 0, 1) == '>') {
|
||||
$quotelevel++;
|
||||
|
@ -642,7 +642,7 @@ class Email
|
|||
$lines[$lineno] .= ' ';
|
||||
}
|
||||
|
||||
while ((strlen($line)>0) && ((substr($line, 0, 1) == '>')
|
||||
while ((strlen($line) > 0) && ((substr($line, 0, 1) == '>')
|
||||
|| (substr($line, 0, 1) == ' '))) {
|
||||
|
||||
$line = ltrim(substr($line, 1));
|
||||
|
@ -663,34 +663,35 @@ class Email
|
|||
private static function convertQuote(string $body, string $reply): string
|
||||
{
|
||||
// Convert Quotes
|
||||
$arrbody = explode("\n", trim($body));
|
||||
$arrbody = explode("\n", trim($body));
|
||||
$arrlevel = [];
|
||||
|
||||
for ($i = 0; $i < count($arrbody); $i++) {
|
||||
$quotelevel = 0;
|
||||
$quoteline = $arrbody[$i];
|
||||
$quoteline = $arrbody[$i];
|
||||
|
||||
while ((strlen($quoteline)>0) and ((substr($quoteline, 0, 1) == '>')
|
||||
while ((strlen($quoteline) > 0) and ((substr($quoteline, 0, 1) == '>')
|
||||
|| (substr($quoteline, 0, 1) == ' '))) {
|
||||
if (substr($quoteline, 0, 1) == '>')
|
||||
if (substr($quoteline, 0, 1) == '>') {
|
||||
$quotelevel++;
|
||||
}
|
||||
|
||||
$quoteline = ltrim(substr($quoteline, 1));
|
||||
}
|
||||
|
||||
$arrlevel[$i] = $quotelevel;
|
||||
$arrbody[$i] = $quoteline;
|
||||
$arrbody[$i] = $quoteline;
|
||||
}
|
||||
|
||||
$quotelevel = 0;
|
||||
$quotelevel = 0;
|
||||
$arrbodyquoted = [];
|
||||
|
||||
for ($i = 0; $i < count($arrbody); $i++) {
|
||||
$previousquote = $quotelevel;
|
||||
$quotelevel = $arrlevel[$i];
|
||||
$quotelevel = $arrlevel[$i];
|
||||
|
||||
while ($previousquote < $quotelevel) {
|
||||
$quote = "[quote]";
|
||||
$quote = "[quote]";
|
||||
$arrbody[$i] = $quote.$arrbody[$i];
|
||||
$previousquote++;
|
||||
}
|
||||
|
@ -726,8 +727,8 @@ class Email
|
|||
|
||||
do {
|
||||
$oldmessage = $message;
|
||||
$message = preg_replace('=\[/quote\][\s](.*?)\[quote\]=i', '$1', $message);
|
||||
$message = str_replace('[/quote][quote]', '', $message);
|
||||
$message = preg_replace('=\[/quote\][\s](.*?)\[quote\]=i', '$1', $message);
|
||||
$message = str_replace('[/quote][quote]', '', $message);
|
||||
} while ($message != $oldmessage);
|
||||
|
||||
$quotes = [];
|
||||
|
@ -738,12 +739,12 @@ class Email
|
|||
|
||||
while (($pos = strpos($message, '[quote', $start)) > 0) {
|
||||
$quotes[$pos] = -1;
|
||||
$start = $pos + 7;
|
||||
$start = $pos + 7;
|
||||
$startquotes++;
|
||||
}
|
||||
|
||||
$endquotes = 0;
|
||||
$start = 0;
|
||||
$start = 0;
|
||||
|
||||
while (($pos = strpos($message, '[/quote]', $start)) > 0) {
|
||||
$start = $pos + 7;
|
||||
|
@ -759,7 +760,7 @@ class Email
|
|||
|
||||
while (($pos = strpos($message, '[/quote]', $start)) > 0) {
|
||||
$quotes[$pos] = 1;
|
||||
$start = $pos + 7;
|
||||
$start = $pos + 7;
|
||||
}
|
||||
|
||||
if (strtolower(substr($message, -8)) != '[/quote]') {
|
||||
|
@ -773,12 +774,13 @@ class Email
|
|||
foreach ($quotes as $index => $quote) {
|
||||
$quotelevel += $quote;
|
||||
|
||||
if (($quotelevel == 0) and ($quotestart == 0))
|
||||
if (($quotelevel == 0) and ($quotestart == 0)) {
|
||||
$quotestart = $index;
|
||||
}
|
||||
}
|
||||
|
||||
if ($quotestart != 0) {
|
||||
$message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart+7, -8) . '[/spoiler]';
|
||||
$message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart + 7, -8) . '[/spoiler]';
|
||||
}
|
||||
|
||||
return $message;
|
||||
|
|
|
@ -88,14 +88,14 @@ class Feed
|
|||
$xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
|
||||
$xpath->registerNamespace('poco', ActivityNamespace::POCO);
|
||||
|
||||
$author = [];
|
||||
$atomns = 'atom';
|
||||
$entries = null;
|
||||
$author = [];
|
||||
$atomns = 'atom';
|
||||
$entries = null;
|
||||
$protocol = Conversation::PARCEL_UNKNOWN;
|
||||
|
||||
// Is it RDF?
|
||||
if ($xpath->query('/rdf:RDF/rss:channel')->length > 0) {
|
||||
$protocol = Conversation::PARCEL_RDF;
|
||||
$protocol = Conversation::PARCEL_RDF;
|
||||
$author['author-link'] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:link/text()');
|
||||
$author['author-name'] = XML::getFirstNodeValue($xpath, '/rdf:RDF/rss:channel/rss:title/text()');
|
||||
|
||||
|
@ -106,9 +106,9 @@ class Feed
|
|||
}
|
||||
|
||||
if ($xpath->query('/opml')->length > 0) {
|
||||
$protocol = Conversation::PARCEL_OPML;
|
||||
$protocol = Conversation::PARCEL_OPML;
|
||||
$author['author-name'] = XML::getFirstNodeValue($xpath, '/opml/head/title/text()');
|
||||
$entries = $xpath->query('/opml/body/outline');
|
||||
$entries = $xpath->query('/opml/body/outline');
|
||||
}
|
||||
|
||||
// Is it Atom?
|
||||
|
@ -116,7 +116,7 @@ class Feed
|
|||
$protocol = Conversation::PARCEL_ATOM;
|
||||
} elseif ($xpath->query('/atom03:feed')->length > 0) {
|
||||
$protocol = Conversation::PARCEL_ATOM03;
|
||||
$atomns = 'atom03';
|
||||
$atomns = 'atom03';
|
||||
}
|
||||
|
||||
if (in_array($protocol, [Conversation::PARCEL_ATOM, Conversation::PARCEL_ATOM03])) {
|
||||
|
@ -203,7 +203,7 @@ class Feed
|
|||
|
||||
// Is it RSS?
|
||||
if ($xpath->query('/rss/channel')->length > 0) {
|
||||
$protocol = Conversation::PARCEL_RSS;
|
||||
$protocol = Conversation::PARCEL_RSS;
|
||||
$author['author-link'] = XML::getFirstNodeValue($xpath, '/rss/channel/link/text()');
|
||||
|
||||
$author['author-name'] = XML::getFirstNodeValue($xpath, '/rss/channel/title/text()');
|
||||
|
@ -251,8 +251,8 @@ class Feed
|
|||
|
||||
$author['author-avatar'] = $contact['thumb'];
|
||||
|
||||
$author['owner-link'] = $contact['url'];
|
||||
$author['owner-name'] = $contact['name'];
|
||||
$author['owner-link'] = $contact['url'];
|
||||
$author['owner-name'] = $contact['name'];
|
||||
$author['owner-avatar'] = $contact['thumb'];
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ class Feed
|
|||
'contact-id' => $contact['id'] ?? 0,
|
||||
];
|
||||
|
||||
$datarray['protocol'] = $protocol;
|
||||
$datarray['protocol'] = $protocol;
|
||||
$datarray['direction'] = Conversation::PULL;
|
||||
|
||||
if (!is_object($entries)) {
|
||||
|
@ -277,12 +277,12 @@ class Feed
|
|||
return [];
|
||||
}
|
||||
|
||||
$items = [];
|
||||
$items = [];
|
||||
$creation_dates = [];
|
||||
|
||||
// Limit the number of items that are about to be fetched
|
||||
$total_items = ($entries->length - 1);
|
||||
$max_items = DI::config()->get('system', 'max_feed_items');
|
||||
$max_items = DI::config()->get('system', 'max_feed_items');
|
||||
if (($max_items > 0) && ($total_items > $max_items)) {
|
||||
$total_items = $max_items;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ class Feed
|
|||
if ($entry->nodeName == 'outline') {
|
||||
$isrss = false;
|
||||
$plink = '';
|
||||
$uri = '';
|
||||
$uri = '';
|
||||
foreach ($entry->attributes as $attribute) {
|
||||
switch ($attribute->nodeName) {
|
||||
case 'title':
|
||||
|
@ -336,7 +336,7 @@ class Feed
|
|||
}
|
||||
}
|
||||
$item['plink'] = $plink ?: $uri;
|
||||
$item['uri'] = $uri ?: $plink;
|
||||
$item['uri'] = $uri ?: $plink;
|
||||
if (!$isrss || empty($item['uri'])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -476,9 +476,9 @@ class Feed
|
|||
$enclosures = $xpath->query("enclosure|$atomns:link[@rel='enclosure']", $entry);
|
||||
if (!empty($enclosures)) {
|
||||
foreach ($enclosures as $enclosure) {
|
||||
$href = '';
|
||||
$href = '';
|
||||
$length = null;
|
||||
$type = null;
|
||||
$type = null;
|
||||
|
||||
foreach ($enclosure->attributes as $attribute) {
|
||||
if (in_array($attribute->name, ['url', 'href'])) {
|
||||
|
@ -505,7 +505,7 @@ class Feed
|
|||
}
|
||||
}
|
||||
|
||||
$taglist = [];
|
||||
$taglist = [];
|
||||
$categories = $xpath->query('category', $entry);
|
||||
foreach ($categories as $category) {
|
||||
$taglist[] = $category->nodeValue;
|
||||
|
@ -526,7 +526,7 @@ class Feed
|
|||
}
|
||||
|
||||
if (empty($body)) {
|
||||
$body = $summary;
|
||||
$body = $summary;
|
||||
$summary = '';
|
||||
}
|
||||
|
||||
|
@ -537,16 +537,16 @@ class Feed
|
|||
}
|
||||
|
||||
$item['body'] = self::formatBody($body, $basepath);
|
||||
$summary = self::formatBody($summary, $basepath);
|
||||
$summary = self::formatBody($summary, $basepath);
|
||||
|
||||
if (($item['body'] == '') && ($item['title'] != '')) {
|
||||
$item['body'] = $item['title'];
|
||||
$item['body'] = $item['title'];
|
||||
$item['title'] = '';
|
||||
}
|
||||
|
||||
if ($dryRun) {
|
||||
$item['attachments'] = $attachments;
|
||||
$items[] = $item;
|
||||
$items[] = $item;
|
||||
break;
|
||||
} elseif (!Item::isValid($item)) {
|
||||
DI::logger()->info('Feed item is invalid', ['created' => $item['created'], 'uid' => $item['uid'], 'uri' => $item['uri']]);
|
||||
|
@ -582,7 +582,7 @@ class Feed
|
|||
$summary = '';
|
||||
}
|
||||
|
||||
$saved_body = $item['body'];
|
||||
$saved_body = $item['body'];
|
||||
$saved_title = $item['title'];
|
||||
|
||||
if (self::replaceBodyWithTitle($item['body'], $item['title'])) {
|
||||
|
@ -612,7 +612,7 @@ class Feed
|
|||
// Take the data that was provided by the feed if the query is empty
|
||||
if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) {
|
||||
$data['title'] = $saved_title;
|
||||
$item['body'] = $saved_body;
|
||||
$item['body'] = $saved_body;
|
||||
}
|
||||
|
||||
$data_text = strip_tags(trim($data['text'] ?? ''));
|
||||
|
@ -623,11 +623,11 @@ class Feed
|
|||
}
|
||||
|
||||
// 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 = $fetch_further_information == LocalRelationship::FFI_BOTH ? PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '') : [];
|
||||
$item['title'] = '';
|
||||
$item['body'] = $item['body'] . "\n" . PageInfo::getFooterFromData($data, false);
|
||||
$taglist = $fetch_further_information == LocalRelationship::FFI_BOTH ? PageInfo::getTagsFromUrl($item['plink'], $preview, $contact['ffi_keyword_denylist'] ?? '') : [];
|
||||
$item['object-type'] = Activity\ObjectType::BOOKMARK;
|
||||
$attachments = [];
|
||||
$attachments = [];
|
||||
|
||||
foreach (['audio', 'video'] as $elementname) {
|
||||
if (!empty($data[$elementname])) {
|
||||
|
@ -674,7 +674,7 @@ class Feed
|
|||
|
||||
DI::logger()->info('Stored feed', ['item' => $item]);
|
||||
|
||||
$notify = Item::isRemoteSelf($contact, $item);
|
||||
$notify = Item::isRemoteSelf($contact, $item);
|
||||
$item['wall'] = (bool)$notify;
|
||||
|
||||
// Distributed items should have a well-formatted URI.
|
||||
|
@ -696,7 +696,7 @@ class Feed
|
|||
Post\Delayed::publish($item, $notify, $taglist, $attachments);
|
||||
} else {
|
||||
$postings[] = [
|
||||
'item' => $item, 'notify' => $notify,
|
||||
'item' => $item, 'notify' => $notify,
|
||||
'taglist' => $taglist, 'attachments' => $attachments
|
||||
];
|
||||
}
|
||||
|
@ -707,11 +707,11 @@ class Feed
|
|||
|
||||
if (!empty($postings)) {
|
||||
$min_posting = DI::config()->get('system', 'minimum_posting_interval', 0);
|
||||
$total = count($postings);
|
||||
$total = count($postings);
|
||||
if ($total > 1) {
|
||||
// Posts shouldn't be delayed more than a day
|
||||
$interval = min(1440, self::getPollInterval($contact));
|
||||
$delay = max(round(($interval * 60) / $total), 60 * $min_posting);
|
||||
$delay = max(round(($interval * 60) / $total), 60 * $min_posting);
|
||||
DI::logger()->info('Got posting delay', ['delay' => $delay, 'interval' => $interval, 'items' => $total, 'cid' => $contact['id'], 'url' => $contact['url']]);
|
||||
} else {
|
||||
$delay = 0;
|
||||
|
@ -795,15 +795,15 @@ class Feed
|
|||
|
||||
if (!empty($creation_dates)) {
|
||||
// Count the post frequency and the earliest and latest post date
|
||||
$frequency = [];
|
||||
$oldest = time();
|
||||
$newest = 0;
|
||||
$frequency = [];
|
||||
$oldest = time();
|
||||
$newest = 0;
|
||||
$newest_date = '';
|
||||
|
||||
foreach ($creation_dates as $date) {
|
||||
$timestamp = strtotime($date);
|
||||
$day = intdiv($timestamp, 86400);
|
||||
$hour = $timestamp % 86400;
|
||||
$day = intdiv($timestamp, 86400);
|
||||
$hour = $timestamp % 86400;
|
||||
|
||||
// Only have a look at values from the last seven days
|
||||
if (((time() / 86400) - $day) < 7) {
|
||||
|
@ -824,7 +824,7 @@ class Feed
|
|||
}
|
||||
|
||||
if ($newest < $day) {
|
||||
$newest = $day;
|
||||
$newest = $day;
|
||||
$newest_date = $date;
|
||||
}
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ class Feed
|
|||
|
||||
// Assume at least four hours between oldest and newest post per day - should be okay for news outlets
|
||||
$duration = max($entry['high'] - $entry['low'], 14400);
|
||||
$ppd = (86400 / $duration) * $entry['count'];
|
||||
$ppd = (86400 / $duration) * $entry['count'];
|
||||
if ($ppd > $max) {
|
||||
$max = $ppd;
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ class Feed
|
|||
$pos = strrpos($title, '...');
|
||||
if ($pos > 0) {
|
||||
$title = substr($title, 0, $pos);
|
||||
$body = substr($body, 0, $pos);
|
||||
$body = substr($body, 0, $pos);
|
||||
}
|
||||
}
|
||||
return ($title == $body);
|
||||
|
@ -1019,7 +1019,7 @@ class Feed
|
|||
$previous_created = $last_update;
|
||||
|
||||
$check_date = empty($last_update) ? '' : DateTimeFormat::utc($last_update);
|
||||
$authorid = Contact::getIdForURL($owner['url']);
|
||||
$authorid = Contact::getIdForURL($owner['url']);
|
||||
|
||||
$condition = [
|
||||
"`uid` = ? AND `received` > ? AND NOT `deleted` AND `gravity` IN (?, ?)
|
||||
|
@ -1049,7 +1049,7 @@ class Feed
|
|||
|
||||
$items = Post::toArray($ret);
|
||||
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
||||
$root = self::addHeader($doc, $owner, $filter);
|
||||
|
@ -1085,7 +1085,7 @@ class Feed
|
|||
$root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed');
|
||||
$doc->appendChild($root);
|
||||
|
||||
$title = '';
|
||||
$title = '';
|
||||
$selfUri = '/feed/' . $owner['nick'] . '/';
|
||||
switch ($filter) {
|
||||
case 'activity':
|
||||
|
@ -1198,7 +1198,7 @@ class Feed
|
|||
'link',
|
||||
'',
|
||||
[
|
||||
'rel' => 'alternate', 'type' => 'text/html',
|
||||
'rel' => 'alternate', 'type' => 'text/html',
|
||||
'href' => DI::baseUrl() . '/display/' . $item['guid']
|
||||
]
|
||||
);
|
||||
|
@ -1290,11 +1290,11 @@ class Feed
|
|||
// Remove the share element before fetching the first line
|
||||
$title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $item['body']));
|
||||
|
||||
$title = BBCode::toPlaintext($title) . "\n";
|
||||
$pos = strpos($title, "\n");
|
||||
$title = BBCode::toPlaintext($title) . "\n";
|
||||
$pos = strpos($title, "\n");
|
||||
$trailer = '';
|
||||
if (($pos == 0) || ($pos > 100)) {
|
||||
$pos = 100;
|
||||
$pos = 100;
|
||||
$trailer = '...';
|
||||
}
|
||||
|
||||
|
@ -1347,8 +1347,8 @@ class Feed
|
|||
{
|
||||
foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO, Post\Media::DOCUMENT, Post\Media::TORRENT]) as $attachment) {
|
||||
$attributes = ['rel' => 'enclosure',
|
||||
'href' => $attachment['url'],
|
||||
'type' => $attachment['mimetype']];
|
||||
'href' => $attachment['url'],
|
||||
'type' => $attachment['mimetype']];
|
||||
|
||||
if (!empty($attachment['size'])) {
|
||||
$attributes['length'] = intval($attachment['size']);
|
||||
|
@ -1401,9 +1401,9 @@ class Feed
|
|||
if ($owner['contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$entry->setAttribute('xmlns:activity', ActivityNamespace::ACTIVITY);
|
||||
|
||||
$contact = Contact::getByURL($item['author-link']) ?: $owner;
|
||||
$contact = Contact::getByURL($item['author-link']) ?: $owner;
|
||||
$contact['nickname'] = $contact['nickname'] ?? $contact['nick'];
|
||||
$author = self::addAuthor($doc, $contact);
|
||||
$author = self::addAuthor($doc, $contact);
|
||||
$entry->appendChild($author);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -33,7 +33,7 @@ use Friendica\Util\Strings;
|
|||
class Relay
|
||||
{
|
||||
const SCOPE_NONE = '';
|
||||
const SCOPE_ALL = 'all';
|
||||
const SCOPE_ALL = 'all';
|
||||
const SCOPE_TAGS = 'tags';
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ class Relay
|
|||
|
||||
if (!empty($causerid)) {
|
||||
$contact = Contact::getById($causerid, ['url']);
|
||||
$causer = $contact['url'] ?? '';
|
||||
$causer = $contact['url'] ?? '';
|
||||
} else {
|
||||
$causer = '';
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class Relay
|
|||
if ($scope == self::SCOPE_TAGS) {
|
||||
$tagList = self::getSubscribedTags();
|
||||
} else {
|
||||
$tagList = [];
|
||||
$tagList = [];
|
||||
}
|
||||
|
||||
$denyTags = Strings::getTagArrayByString($config->get('system', 'relay_deny_tags'));
|
||||
|
@ -96,7 +96,7 @@ class Relay
|
|||
|
||||
$max_tags = $config->get('system', 'relay_max_tags');
|
||||
if ($max_tags && (count($tags) > $max_tags) && preg_match('/[^@!#]\[url\=.*?\].*?\[\/url\]/ism', $body)) {
|
||||
$cleaned = preg_replace('/[@!#]\[url\=.*?\].*?\[\/url\]/ism', '', $body);
|
||||
$cleaned = preg_replace('/[@!#]\[url\=.*?\].*?\[\/url\]/ism', '', $body);
|
||||
$content_cleaned = mb_strtolower(BBCode::toPlaintext($cleaned, false));
|
||||
|
||||
if (strlen($content_cleaned) < strlen($content) / 2) {
|
||||
|
@ -223,12 +223,12 @@ class Relay
|
|||
}
|
||||
|
||||
$condition = ['uid' => 0, 'gsid' => $gserver['id'], 'contact-type' => Contact::TYPE_RELAY];
|
||||
$old = DBA::selectFirst('contact', [], $condition);
|
||||
$old = DBA::selectFirst('contact', [], $condition);
|
||||
if (!DBA::isResult($old)) {
|
||||
$condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($gserver['url'])];
|
||||
$old = DBA::selectFirst('contact', [], $condition);
|
||||
$old = DBA::selectFirst('contact', [], $condition);
|
||||
if (DBA::isResult($old)) {
|
||||
$fields['gsid'] = $gserver['id'];
|
||||
$fields['gsid'] = $gserver['id'];
|
||||
$fields['contact-type'] = Contact::TYPE_RELAY;
|
||||
DI::logger()->info('Assigning missing data for relay contact', ['server' => $gserver['url'], 'id' => $old['id']]);
|
||||
}
|
||||
|
@ -245,15 +245,15 @@ class Relay
|
|||
Contact::update($fields, ['id' => $old['id']], $old);
|
||||
} else {
|
||||
$default = ['created' => DateTimeFormat::utcNow(),
|
||||
'name' => 'relay', 'nick' => 'relay', 'url' => $gserver['url'],
|
||||
'nurl' => Strings::normaliseLink($gserver['url']),
|
||||
'network' => Protocol::DIASPORA, 'uid' => 0,
|
||||
'batch' => $gserver['url'] . '/receive/public',
|
||||
'rel' => Contact::FOLLOWER, 'blocked' => false,
|
||||
'pending' => false, 'writable' => true,
|
||||
'gsid' => $gserver['id'],
|
||||
'unsearchable' => true,
|
||||
'baseurl' => $gserver['url'], 'contact-type' => Contact::TYPE_RELAY];
|
||||
'name' => 'relay', 'nick' => 'relay', 'url' => $gserver['url'],
|
||||
'nurl' => Strings::normaliseLink($gserver['url']),
|
||||
'network' => Protocol::DIASPORA, 'uid' => 0,
|
||||
'batch' => $gserver['url'] . '/receive/public',
|
||||
'rel' => Contact::FOLLOWER, 'blocked' => false,
|
||||
'pending' => false, 'writable' => true,
|
||||
'gsid' => $gserver['id'],
|
||||
'unsearchable' => true,
|
||||
'baseurl' => $gserver['url'], 'contact-type' => Contact::TYPE_RELAY];
|
||||
|
||||
$fields = array_merge($default, $fields);
|
||||
|
||||
|
@ -278,14 +278,14 @@ class Relay
|
|||
$relay_contact = $contact;
|
||||
} elseif (empty($contact['baseurl'])) {
|
||||
if (!empty($contact['batch'])) {
|
||||
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => Contact::TYPE_RELAY];
|
||||
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => Contact::TYPE_RELAY];
|
||||
$relay_contact = DBA::selectFirst('contact', [], $condition);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$gserver = ['id' => $contact['gsid'] ?: GServer::getID($contact['baseurl'], true),
|
||||
'url' => $contact['baseurl'], 'network' => $contact['network']];
|
||||
'url' => $contact['baseurl'], 'network' => $contact['network']];
|
||||
$relay_contact = self::getContact($gserver, []);
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ class Relay
|
|||
DBA::close($servers);
|
||||
|
||||
// All tags of the current post
|
||||
$tags = DBA::select('tag-view', ['name'], ['uri-id' => $parent['uri-id'], 'type' => Tag::HASHTAG]);
|
||||
$tags = DBA::select('tag-view', ['name'], ['uri-id' => $parent['uri-id'], 'type' => Tag::HASHTAG]);
|
||||
$taglist = [];
|
||||
while ($tag = DBA::fetch($tags)) {
|
||||
$taglist[] = $tag['name'];
|
||||
|
@ -376,8 +376,11 @@ class Relay
|
|||
*/
|
||||
public static function getList(array $fields = []): array
|
||||
{
|
||||
return DBA::selectToArray('apcontact', $fields,
|
||||
["`type` IN (?, ?) AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` = ?)", 'Application', 'Service', 0, Contact::FRIEND]);
|
||||
return DBA::selectToArray(
|
||||
'apcontact',
|
||||
$fields,
|
||||
["`type` IN (?, ?) AND `url` IN (SELECT `url` FROM `contact` WHERE `uid` = ? AND `rel` = ?)", 'Application', 'Service', 0, Contact::FRIEND]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,7 +395,7 @@ class Relay
|
|||
{
|
||||
// Fetch the relay contact
|
||||
$condition = ['uid' => 0, 'gsid' => $gserver['id'], 'contact-type' => Contact::TYPE_RELAY];
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
$contact = DBA::selectFirst('contact', $fields, $condition);
|
||||
if (DBA::isResult($contact)) {
|
||||
if ($contact['archive'] || $contact['blocked']) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue