Compare commits

...

11 commits

Author SHA1 Message Date
Hypolite Petovan aa5130247b [pumpio] Remove two superfluous parentheses
- Thanks to @SteffenK9 for the report!
2024-11-16 21:19:06 -05:00
Hypolite Petovan aeefb92926 Merge pull request 'Connectors: Fix handling of the 'private' field / reformatted code' (#1564) from heluecht/friendica-addons:private into 2024.09-rc
Reviewed-on: friendica/friendica-addons#1564
Reviewed-by: Hypolite Petovan <hypolite@mrpetovan.com>
2024-11-16 19:15:37 +01:00
Michael c22e0ae831 Fix handling of the 'private' field / reformatted code 2024-11-16 05:43:35 +00:00
Tobias Diekershoff f499875f5b Merge pull request 'Bluesky/Tumblr: Add "connector" parcel to each incoming post' (#1561) from heluecht/friendica-addons:parcel into 2024.09-rc
Reviewed-on: friendica/friendica-addons#1561
2024-11-13 10:16:35 +01:00
Michael 6a1cbe9040 Bluesky/Tumblr: Add "connector" parcel to each incoming post 2024-11-13 10:16:35 +01:00
Tobias Diekershoff 6980d3b02b Merge pull request 'deprecate fancybox addon' (#1563) from tobias/friendica-addons:2024.09-rc into 2024.09-rc
Reviewed-on: friendica/friendica-addons#1563
2024-11-13 10:11:50 +01:00
Tobias Diekershoff e89b5b1466 deprecate fancybox addon
replaces #1562
2024-11-13 10:10:25 +01:00
Tobias Diekershoff 5638e7f065 Merge pull request 'Bluesky: Fix probe mistake' (#1560) from heluecht/friendica-addons:bluesky-full-path into 2024.09-rc
Reviewed-on: friendica/friendica-addons#1560
2024-10-30 07:33:34 +01:00
Michael 4165479079 Bluesky: Fix probe mistake 2024-10-30 05:11:50 +00:00
Tobias Diekershoff fca2d609c9 Merge pull request 'Bluesky: Fix following of a contact and adding a post' (#1559) from heluecht/friendica-addons:bluesky-fix-follow into 2024.09-rc
Reviewed-on: friendica/friendica-addons#1559
2024-10-27 08:42:34 +01:00
Michael 8b694fbb4c Bluesky: Fix following of a contact and adding a post 2024-10-27 04:50:45 +00:00
13 changed files with 159 additions and 177 deletions

View file

@ -38,6 +38,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\GServer; use Friendica\Model\GServer;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\ItemURI; use Friendica\Model\ItemURI;
@ -139,7 +140,7 @@ function bluesky_probe_detect(array &$hookData)
return; return;
} }
} elseif (Network::isValidHttpUrl($hookData['uri'])) { } elseif (Network::isValidHttpUrl($hookData['uri'])) {
$did = bluesky_get_did_by_profile($hookData['uri']); $did = bluesky_get_did_by_profile($hookData['uri'], $pconfig['uid']);
if (empty($did)) { if (empty($did)) {
return; return;
} }
@ -181,21 +182,21 @@ function bluesky_item_by_link(array &$hookData)
return; return;
} }
$did = bluesky_get_did_by_profile($hookData['uri']); if (!preg_match('#^' . BLUESKY_WEB . '/profile/(.+)/post/(.+)#', $hookData['uri'], $matches)) {
return;
}
$did = bluesky_get_did($matches[1], $hookData['uid']);
if (empty($did)) { if (empty($did)) {
return; return;
} }
if (!preg_match('#/profile/.+/post/(.+)#', $hookData['uri'], $matches)) { Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
return;
}
Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[1]]); $uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[1];
$uri = bluesky_fetch_missing_post($uri, $hookData['uid'], $hookData['uid'], Item::PR_FETCHED, 0, 0, 0); $uri = bluesky_fetch_missing_post($uri, $hookData['uid'], $hookData['uid'], Item::PR_FETCHED, 0, 0, 0);
Logger::debug('Got post', ['did' => $did, 'cid' => $matches[1], 'result' => $uri]); Logger::debug('Got post', ['did' => $did, 'cid' => $matches[2], 'result' => $uri]);
if (!empty($uri)) { if (!empty($uri)) {
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]); $item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
if (!empty($item['id'])) { if (!empty($item['id'])) {
@ -586,13 +587,13 @@ function bluesky_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) { if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
// Don't post if it isn't a reply to a bluesky post // Don't post if it isn't a reply to a bluesky post
if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) { if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
Logger::notice('No bluesky parent found', ['item' => $post['id']]); Logger::notice('No bluesky parent found', ['item' => $post['id']]);
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
} elseif (!strstr($post['postopts'] ?? '', 'bluesky') || ($post['parent'] != $post['id']) || $post['private']) { } elseif (!strstr($post['postopts'] ?? '', 'bluesky') || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
DI::logger()->info('Activities are never exported when we don\'t import the bluesky timeline', ['uid' => $post['uid']]); DI::logger()->info('Post will not be exported', ['uid' => $post['uid'], 'postopts' => $post['postopts'], 'gravity' => $post['gravity'], 'private' => $post['private']]);
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -600,15 +601,11 @@ function bluesky_hook_fork(array &$b)
function bluesky_post_local(array &$b) function bluesky_post_local(array &$b)
{ {
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -666,7 +663,7 @@ function bluesky_send(array &$b)
bluesky_create_activity($b, $parent); bluesky_create_activity($b, $parent);
} }
return; return;
} elseif ($b['private'] || !strstr($b['postopts'], 'bluesky')) { } elseif (($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'bluesky')) {
return; return;
} }
@ -1058,6 +1055,7 @@ function bluesky_process_reason(stdClass $reason, string $uri, int $uid)
$item = [ $item = [
'network' => Protocol::BLUESKY, 'network' => Protocol::BLUESKY,
'protocol' => Conversation::PARCEL_CONNECTOR,
'uid' => $uid, 'uid' => $uid,
'wall' => false, 'wall' => false,
'uri' => $reason->by->did . '/app.bsky.feed.repost/' . $reason->indexedAt, 'uri' => $reason->by->did . '/app.bsky.feed.repost/' . $reason->indexedAt,
@ -1257,6 +1255,7 @@ function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_ui
$contact = bluesky_get_contact($post->author, $uid, $fetch_uid); $contact = bluesky_get_contact($post->author, $uid, $fetch_uid);
$item = [ $item = [
'network' => Protocol::BLUESKY, 'network' => Protocol::BLUESKY,
'protocol' => Conversation::PARCEL_CONNECTOR,
'uid' => $uid, 'uid' => $uid,
'wall' => false, 'wall' => false,
'uri' => $uri, 'uri' => $uri,
@ -1459,8 +1458,8 @@ function bluesky_add_media(stdClass $embed, array $item, int $fetch_uid, int $le
'url' => $embed->playlist, 'url' => $embed->playlist,
'preview' => $embed->thumbnail, 'preview' => $embed->thumbnail,
'description' => $embed->alt ?? '', 'description' => $embed->alt ?? '',
'height' => $embed->aspectRatio->height, 'height' => $embed->aspectRatio->height ?? null,
'width' => $embed->aspectRatio->width, 'width' => $embed->aspectRatio->width ?? null,
]; ];
Post\Media::insert($media); Post\Media::insert($media);
break; break;
@ -1478,6 +1477,18 @@ function bluesky_add_media(stdClass $embed, array $item, int $fetch_uid, int $le
case 'app.bsky.embed.record#view': case 'app.bsky.embed.record#view':
$original_uri = $uri = bluesky_get_uri($embed->record); $original_uri = $uri = bluesky_get_uri($embed->record);
$type = '$type';
if (!empty($embed->record->record->$type)) {
$embed_type = $embed->record->record->$type;
if ($embed_type == 'app.bsky.graph.starterpack') {
Logger::debug('Starterpacks are not fetched like posts', ['original-uri' => $original_uri]);
if (empty($item['body'])) {
// @todo process starterpack
$item['body'] = '[url=' . $embed->record->record->list . ']' . $embed->record->record->name . '[/url]';
}
break;
}
}
$uri = bluesky_fetch_missing_post($uri, $item['uid'], $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll); $uri = bluesky_fetch_missing_post($uri, $item['uid'], $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
if ($uri) { if ($uri) {
$shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$item['uid'], 0]]); $shared = Post::selectFirst(['uri-id'], ['uri' => $uri, 'uid' => [$item['uid'], 0]]);
@ -1831,8 +1842,14 @@ function bluesky_get_preferences(int $uid): ?stdClass
return $data; return $data;
} }
function bluesky_get_did_by_profile(string $url): string function bluesky_get_did_by_profile(string $url, int $uid): string
{ {
if (preg_match('#^' . BLUESKY_WEB . '/profile/(.+)#', $url, $matches)) {
$did = bluesky_get_did($matches[1], $uid);
if (!empty($did)) {
return $did;
}
}
try { try {
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]); $curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::CONTACTINFO]);
} catch (\Throwable $th) { } catch (\Throwable $th) {
@ -1941,13 +1958,6 @@ function bluesky_get_did(string $handle, int $uid): string
return $did; return $did;
} }
// The profile page can contain hints to the DID as well
$did = bluesky_get_did_by_profile('https://' . $handle);
if ($did != '') {
Logger::debug('Got DID by profile page', ['handle' => $handle, 'did' => $did]);
return $did;
}
// And finally we use the default PDS from Bluesky. // And finally we use the default PDS from Bluesky.
$data = bluesky_get(BLUESKY_PDS . '/xrpc/com.atproto.identity.resolveHandle?handle=' . urlencode($handle)); $data = bluesky_get(BLUESKY_PDS . '/xrpc/com.atproto.identity.resolveHandle?handle=' . urlencode($handle));
if (!empty($data) && !empty($data->did)) { if (!empty($data) && !empty($data->did)) {

View file

@ -17,6 +17,7 @@ use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
function diaspora_install() function diaspora_install()
@ -144,8 +145,10 @@ function diaspora_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || if (
!strstr($post['postopts'] ?? '', 'diaspora') || ($post['parent'] != $post['id'])) { $post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
!strstr($post['postopts'] ?? '', 'diaspora') || ($post['gravity'] != Item::GRAVITY_PARENT)
) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -153,15 +156,11 @@ function diaspora_hook_fork(array &$b)
function diaspora_post_local(array &$b) function diaspora_post_local(array &$b)
{ {
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -190,7 +189,7 @@ function diaspora_send(array &$b)
Logger::notice('diaspora_send: invoked'); Logger::notice('diaspora_send: invoked');
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -14,6 +14,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
@ -88,16 +89,12 @@ function dwpost_settings_post(array &$b)
function dwpost_post_local(array &$b) function dwpost_post_local(array &$b)
{ {
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
if ((!DI::userSession()->getLocalUserId()) || (DI::userSession()->getLocalUserId() != $b['uid'])) { if ((!DI::userSession()->getLocalUserId()) || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { // This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -122,7 +119,7 @@ function dwpost_post_local(array &$b)
function dwpost_send(array &$b) function dwpost_send(array &$b)
{ {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -4,6 +4,7 @@
* Description: Open media attachments of posts into a fancybox overlay. * Description: Open media attachments of posts into a fancybox overlay.
* Version: 1.05 * Version: 1.05
* Author: Grischa Brockhaus <grischa@brockha.us> * Author: Grischa Brockhaus <grischa@brockha.us>
* Status: Unsupported
*/ */
use Friendica\App; use Friendica\App;

View file

@ -14,6 +14,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -85,17 +86,12 @@ function ijpost_settings_post(array &$b)
function ijpost_post_local(array &$b) function ijpost_post_local(array &$b)
{ {
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { // This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -120,7 +116,7 @@ function ijpost_post_local(array &$b)
function ijpost_send(array &$b) function ijpost_send(array &$b)
{ {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -13,6 +13,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
function libertree_install() function libertree_install()
@ -78,9 +79,7 @@ function libertree_settings_post(array &$b)
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default', intval($_POST['libertree_bydefault'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default', intval($_POST['libertree_bydefault']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_api_token', trim($_POST['libertree_api_token'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_api_token', trim($_POST['libertree_api_token']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url', trim($_POST['libertree_url'])); DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url', trim($_POST['libertree_url']));
} }
} }
function libertree_hook_fork(array &$b) function libertree_hook_fork(array &$b)
@ -91,8 +90,10 @@ function libertree_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || if (
!strstr($post['postopts'], 'libertree') || ($post['parent'] != $post['id'])) { $post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
!strstr($post['postopts'], 'libertree') || ($post['gravity'] != Item::GRAVITY_PARENT)
) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -100,18 +101,12 @@ function libertree_hook_fork(array &$b)
function libertree_post_local(array &$b) function libertree_post_local(array &$b)
{ {
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { // This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -138,7 +133,7 @@ function libertree_send(array &$b)
{ {
Logger::notice('libertree_send: invoked'); Logger::notice('libertree_send: invoked');
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -14,6 +14,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
@ -86,16 +87,12 @@ function ljpost_settings_post(array &$b)
function ljpost_post_local(array &$b) function ljpost_post_local(array &$b)
{ {
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { // This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -118,7 +115,7 @@ function ljpost_post_local(array &$b)
function ljpost_send(array &$b) function ljpost_send(array &$b)
{ {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -18,6 +18,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use phpnut\phpnutException; use phpnut\phpnutException;
@ -221,7 +222,7 @@ function pnut_hook_fork(array &$b)
return; return;
} }
if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['parent'] != $post['id']) || $post['private']) { if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -229,15 +230,11 @@ function pnut_hook_fork(array &$b)
function pnut_post_local(array &$b) function pnut_post_local(array &$b)
{ {
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -265,7 +262,7 @@ function pnut_post_hook(array &$b)
/** /**
* Post to pnut.io * Post to pnut.io
*/ */
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -345,14 +345,14 @@ function pumpio_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) { if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
// Don't fork if it isn't a reply to a pump.io post // Don't fork if it isn't a reply to a pump.io post
if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) { if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
Logger::notice('No pump.io parent found for item ' . $post['id']); Logger::notice('No pump.io parent found for item ' . $post['id']);
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
} else { } else {
// Comments are never exported when we don't import the pumpio timeline // Comments are never exported when we don't import the pumpio timeline
if (!strstr($post['postopts'], 'pumpio') || ($post['parent'] != $post['id']) || $post['private']) { if (!strstr($post['postopts'], 'pumpio') || ($post['gravity'] != Item::GRAVITY_PARENT)|| ($post['private'] == Item::PRIVATE)) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -412,7 +412,7 @@ function pumpio_send(array &$b)
Logger::notice('pumpio_send: receiver ', $receiver); Logger::notice('pumpio_send: receiver ', $receiver);
if (!count($receiver) && ($b['private'] || !strstr($b['postopts'], 'pumpio'))) { if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
return; return;
} }
@ -1319,7 +1319,7 @@ function pumpio_getreceiver(array $b)
{ {
$receiver = []; $receiver = [];
if (!$b['private']) { if ($b['private'] != Item::PRIVATE) {
if (!strstr($b['postopts'], 'pumpio')) { if (!strstr($b['postopts'], 'pumpio')) {
return $receiver; return $receiver;
} }

View file

@ -296,7 +296,7 @@ function statusnet_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ($post['deleted'] || ($post['created'] !== $post['edited']) || strpos($post['postopts'] ?? '', 'statusnet') === false || ($post['parent'] != $post['id']) || $post['private']) { if ($post['deleted'] || ($post['created'] !== $post['edited']) || strpos($post['postopts'] ?? '', 'statusnet') === false || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -336,7 +336,7 @@ function statusnet_post_hook(array &$b)
/** /**
* Post to GNU Social * Post to GNU Social
*/ */
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }
@ -439,11 +439,13 @@ function statusnet_addon_admin_post()
$secret = trim($_POST['secret'][$id]); $secret = trim($_POST['secret'][$id]);
$key = trim($_POST['key'][$id]); $key = trim($_POST['key'][$id]);
//$applicationname = (!empty($_POST['applicationname']) ? Strings::escapeTags(trim($_POST['applicationname'][$id])):''); //$applicationname = (!empty($_POST['applicationname']) ? Strings::escapeTags(trim($_POST['applicationname'][$id])):'');
if ($sitename != '' && if (
$sitename != '' &&
$apiurl != '' && $apiurl != '' &&
$secret != '' && $secret != '' &&
$key != '' && $key != '' &&
empty($_POST['delete'][$id])) { empty($_POST['delete'][$id])
) {
$sites[] = [ $sites[] = [
'sitename' => $sitename, 'sitename' => $sitename,

View file

@ -22,6 +22,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\Post; use Friendica\Model\Post;
@ -31,7 +32,6 @@ use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions; use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
@ -477,13 +477,13 @@ function tumblr_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'tumblr', 'import')) { if (DI::pConfig()->get($post['uid'], 'tumblr', 'import')) {
// Don't post if it isn't a reply to a tumblr post // Don't post if it isn't a reply to a tumblr post
if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) { if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) {
Logger::notice('No tumblr parent found', ['item' => $post['id']]); Logger::notice('No tumblr parent found', ['item' => $post['id']]);
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
} elseif (!strstr($post['postopts'] ?? '', 'tumblr') || ($post['parent'] != $post['id']) || $post['private']) { } elseif (!strstr($post['postopts'] ?? '', 'tumblr') || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
DI::logger()->info('Activities are never exported when we don\'t import the tumblr timeline', ['uid' => $post['uid']]); DI::logger()->info('Post will not be exported', ['uid' => $post['uid'], 'postopts' => $post['postopts'], 'gravity' => $post['gravity'], 'private' => $post['private']]);
$b['execute'] = false; $b['execute'] = false;
return; return;
} }
@ -491,15 +491,11 @@ function tumblr_hook_fork(array &$b)
function tumblr_post_local(array &$b) function tumblr_post_local(array &$b)
{ {
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -575,7 +571,7 @@ function tumblr_send(array &$b)
} }
} }
return; return;
} elseif ($b['private'] || !strstr($b['postopts'], 'tumblr')) { } elseif (($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'tumblr')) {
return; return;
} }
@ -850,6 +846,7 @@ function tumblr_get_header(stdClass $post, string $uri, int $uid): array
$contact = tumblr_get_contact($post->blog, $uid); $contact = tumblr_get_contact($post->blog, $uid);
$item = [ $item = [
'network' => Protocol::TUMBLR, 'network' => Protocol::TUMBLR,
'protocol' => Conversation::PARCEL_CONNECTOR,
'uid' => $uid, 'uid' => $uid,
'wall' => false, 'wall' => false,
'uri' => $uri, 'uri' => $uri,

View file

@ -170,7 +170,7 @@ function twitter_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ( if (
$post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || $post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
!strstr($post['postopts'], 'twitter') || ($post['gravity'] != Item::GRAVITY_PARENT) !strstr($post['postopts'], 'twitter') || ($post['gravity'] != Item::GRAVITY_PARENT)
) { ) {
$b['execute'] = false; $b['execute'] = false;
@ -184,7 +184,7 @@ function twitter_post_local(array &$b)
return; return;
} }
if ($b['edit'] || $b['private'] || $b['parent']) { if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -211,7 +211,7 @@ function twitter_post_hook(array &$b)
{ {
DI::logger()->debug('Invoke post hook', $b); DI::logger()->debug('Invoke post hook', $b);
if (($b['gravity'] != Item::GRAVITY_PARENT) || !strstr($b['postopts'], 'twitter') || $b['private'] || $b['deleted'] || ($b['created'] !== $b['edited'])) { if (($b['gravity'] != Item::GRAVITY_PARENT) || !strstr($b['postopts'], 'twitter') || ($b['private'] == Item::PRIVATE) || $b['deleted'] || ($b['created'] !== $b['edited'])) {
return; return;
} }

View file

@ -108,8 +108,8 @@ function wppost_hook_fork(array &$b)
$post = $b['data']; $post = $b['data'];
if ( if (
$post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) || $post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
!strstr($post['postopts'] ?? '', 'wppost') || ($post['parent'] != $post['id']) !strstr($post['postopts'] ?? '', 'wppost') || ($post['gravity'] != Item::GRAVITY_PARENT)
) { ) {
$b['execute'] = false; $b['execute'] = false;
return; return;
@ -118,18 +118,12 @@ function wppost_hook_fork(array &$b)
function wppost_post_local(array &$b) function wppost_post_local(array &$b)
{ {
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) { if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return; return;
} }
if ($b['private'] || $b['parent']) { // This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
return; return;
} }
@ -152,12 +146,9 @@ function wppost_post_local(array &$b)
$b['postopts'] .= 'wppost'; $b['postopts'] .= 'wppost';
} }
function wppost_send(array &$b) function wppost_send(array &$b)
{ {
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) { if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return; return;
} }