Compare commits
1 commit
2024.09-rc
...
task/compo
Author | SHA1 | Date | |
---|---|---|---|
eaae194bc4 |
|
@ -461,7 +461,7 @@ function blockbot_is_social_media(array $parts): bool
|
||||||
|
|
||||||
$agents = [
|
$agents = [
|
||||||
'facebookexternalhit', 'twitterbot', 'mastodon', 'facebookexternalua',
|
'facebookexternalhit', 'twitterbot', 'mastodon', 'facebookexternalua',
|
||||||
'friendica', 'diasporafederation', 'buzzrelay', 'activityrelay', 'drupal',
|
'friendica', 'diasporafederation', 'buzzrelay', 'activityrelay',
|
||||||
'aoderelay', 'ap-relay', 'peertube', 'misskey', 'pleroma', 'foundkey', 'akkoma',
|
'aoderelay', 'ap-relay', 'peertube', 'misskey', 'pleroma', 'foundkey', 'akkoma',
|
||||||
'lemmy', 'calckey', 'mobilizon', 'zot', 'camo-rs', 'gotosocial', 'pixelfed',
|
'lemmy', 'calckey', 'mobilizon', 'zot', 'camo-rs', 'gotosocial', 'pixelfed',
|
||||||
'pixelfedbot', 'app.wafrn.net', 'go-camo', 'http://a.gup.pe', 'iceshrimp',
|
'pixelfedbot', 'app.wafrn.net', 'go-camo', 'http://a.gup.pe', 'iceshrimp',
|
||||||
|
|
|
@ -38,7 +38,6 @@ 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;
|
||||||
|
@ -140,7 +139,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'], $pconfig['uid']);
|
$did = bluesky_get_did_by_profile($hookData['uri']);
|
||||||
if (empty($did)) {
|
if (empty($did)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,21 +181,21 @@ function bluesky_item_by_link(array &$hookData)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('#^' . BLUESKY_WEB . '/profile/(.+)/post/(.+)#', $hookData['uri'], $matches)) {
|
$did = bluesky_get_did_by_profile($hookData['uri']);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$did = bluesky_get_did($matches[1], $hookData['uid']);
|
|
||||||
if (empty($did)) {
|
if (empty($did)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
|
if (!preg_match('#/profile/.+/post/(.+)#', $hookData['uri'], $matches)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
|
Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[1]]);
|
||||||
|
|
||||||
|
$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[2], 'result' => $uri]);
|
Logger::debug('Got post', ['did' => $did, 'cid' => $matches[1], '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'])) {
|
||||||
|
@ -279,12 +278,14 @@ function bluesky_block(array &$hook_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hook_data['contact']['network'] != Protocol::BLUESKY) {
|
Logger::debug('Check if contact is bluesky', ['data' => $hook_data]);
|
||||||
|
$contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]);
|
||||||
|
if (empty($contact)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$record = [
|
$record = [
|
||||||
'subject' => $hook_data['contact']['url'],
|
'subject' => $contact['url'],
|
||||||
'createdAt' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
'createdAt' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
|
||||||
'$type' => 'app.bsky.graph.block'
|
'$type' => 'app.bsky.graph.block'
|
||||||
];
|
];
|
||||||
|
@ -587,13 +588,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['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
|
if (($post['parent'] != $post['id']) && !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['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
|
} elseif (!strstr($post['postopts'] ?? '', 'bluesky') || ($post['parent'] != $post['id']) || $post['private']) {
|
||||||
DI::logger()->info('Post will not be exported', ['uid' => $post['uid'], 'postopts' => $post['postopts'], 'gravity' => $post['gravity'], 'private' => $post['private']]);
|
DI::logger()->info('Activities are never exported when we don\'t import the bluesky timeline', ['uid' => $post['uid']]);
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -601,11 +602,15 @@ 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['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
if ($b['private'] || $b['parent']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +668,7 @@ function bluesky_send(array &$b)
|
||||||
bluesky_create_activity($b, $parent);
|
bluesky_create_activity($b, $parent);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} elseif (($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'bluesky')) {
|
} elseif ($b['private'] || !strstr($b['postopts'], 'bluesky')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,7 +1041,7 @@ function bluesky_complete_post(stdClass $post, int $uid, int $post_reason, int $
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($complete) {
|
if ($complete) {
|
||||||
$uri = bluesky_fetch_missing_post(bluesky_get_uri($post), $uid, $uid, $post_reason, $causer, 0, $last_poll, '', true);
|
$uri = bluesky_fetch_missing_post($post->uri, $uid, $uid, $post_reason, $causer, 0, $last_poll, '', true);
|
||||||
$uri_id = bluesky_fetch_uri_id($uri, $uid);
|
$uri_id = bluesky_fetch_uri_id($uri, $uid);
|
||||||
} else {
|
} else {
|
||||||
$uri_id = bluesky_process_post($post, $uid, $uid, $post_reason, $causer, 0, $last_poll);
|
$uri_id = bluesky_process_post($post, $uid, $uid, $post_reason, $causer, 0, $last_poll);
|
||||||
|
@ -1055,11 +1060,11 @@ 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,
|
||||||
'private' => Item::UNLISTED,
|
'private' => Item::UNLISTED,
|
||||||
|
'verb' => Activity::POST,
|
||||||
'contact-id' => $contact['id'],
|
'contact-id' => $contact['id'],
|
||||||
'author-name' => $contact['name'],
|
'author-name' => $contact['name'],
|
||||||
'author-link' => $contact['url'],
|
'author-link' => $contact['url'],
|
||||||
|
@ -1254,7 +1259,6 @@ 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,
|
||||||
|
@ -1293,7 +1297,6 @@ function bluesky_get_header(stdClass $post, string $uri, int $uid, int $fetch_ui
|
||||||
// When "ver" is set to "1" it was flagged by some automated process.
|
// When "ver" is set to "1" it was flagged by some automated process.
|
||||||
if (empty($label->ver)) {
|
if (empty($label->ver)) {
|
||||||
$item['sensitive'] = true;
|
$item['sensitive'] = true;
|
||||||
$item['content-warning'] = $label->val ?? '';
|
|
||||||
Logger::debug('Sensitive content', ['uri-id' => $item['uri-id'], 'label' => $label]);
|
Logger::debug('Sensitive content', ['uri-id' => $item['uri-id'], 'label' => $label]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1457,8 +1460,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 ?? null,
|
'height' => $embed->aspectRatio->height,
|
||||||
'width' => $embed->aspectRatio->width ?? null,
|
'width' => $embed->aspectRatio->width,
|
||||||
];
|
];
|
||||||
Post\Media::insert($media);
|
Post\Media::insert($media);
|
||||||
break;
|
break;
|
||||||
|
@ -1476,20 +1479,7 @@ 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';
|
$uri = bluesky_fetch_missing_post($uri, $item['uid'], $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
|
||||||
if (!empty($embed->record->record->$type)) {
|
|
||||||
$embed_type = $embed->record->record->$type;
|
|
||||||
if ($embed_type == 'app.bsky.graph.starterpack') {
|
|
||||||
bluesky_add_starterpack($item, $embed->record);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$fetched_uri = bluesky_fetch_post($uri, $item['uid']);
|
|
||||||
if (!$fetched_uri) {
|
|
||||||
$uri = bluesky_fetch_missing_post($uri, 0, $fetch_uid, Item::PR_FETCHED, $item['contact-id'], $level, $last_poll);
|
|
||||||
} else {
|
|
||||||
$uri = $fetched_uri;
|
|
||||||
}
|
|
||||||
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]]);
|
||||||
$uri_id = $shared['uri-id'] ?? 0;
|
$uri_id = $shared['uri-id'] ?? 0;
|
||||||
|
@ -1523,30 +1513,6 @@ function bluesky_add_media(stdClass $embed, array $item, int $fetch_uid, int $le
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bluesky_add_starterpack(array $item, stdClass $record)
|
|
||||||
{
|
|
||||||
Logger::debug('Received starterpack', ['uri-id' => $item['uri-id'], 'guid' => $item['guid'], 'uri' => $record->uri]);
|
|
||||||
if (!preg_match('#^at://(.+)/app.bsky.graph.starterpack/(.+)#', $record->uri, $matches)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$media = [
|
|
||||||
'uri-id' => $item['uri-id'],
|
|
||||||
'type' => Post\Media::HTML,
|
|
||||||
'url' => 'https://bsky.app/starter-pack/' . $matches[1] . '/' . $matches[2],
|
|
||||||
'name' => $record->record->name,
|
|
||||||
'description' => $record->record->description,
|
|
||||||
];
|
|
||||||
|
|
||||||
Post\Media::insert($media);
|
|
||||||
|
|
||||||
$fields = [
|
|
||||||
'name' => $record->record->name,
|
|
||||||
'description' => $record->record->description,
|
|
||||||
];
|
|
||||||
Post\Media::update($fields, ['uri-id' => $media['uri-id'], 'url' => $media['url']]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function bluesky_get_uri(stdClass $post): string
|
function bluesky_get_uri(stdClass $post): string
|
||||||
{
|
{
|
||||||
if (empty($post->cid)) {
|
if (empty($post->cid)) {
|
||||||
|
@ -1651,7 +1617,7 @@ function bluesky_fetch_parents(stdClass $parent, int $uid, array $parents = []):
|
||||||
$parents = bluesky_fetch_parents($parent->parent, $uid, $parents);
|
$parents = bluesky_fetch_parents($parent->parent, $uid, $parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($parent->post) && empty(bluesky_fetch_post(bluesky_get_uri($parent->post), $uid))) {
|
if (empty(bluesky_fetch_post(bluesky_get_uri($parent->post), $uid))) {
|
||||||
$parents[] = $parent->post;
|
$parents[] = $parent->post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1866,14 +1832,8 @@ function bluesky_get_preferences(int $uid): ?stdClass
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bluesky_get_did_by_profile(string $url, int $uid): string
|
function bluesky_get_did_by_profile(string $url): 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) {
|
||||||
|
@ -1982,6 +1942,13 @@ 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)) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ 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()
|
||||||
|
@ -121,15 +120,15 @@ function diaspora_settings(array &$data)
|
||||||
function diaspora_settings_post(array &$b)
|
function diaspora_settings_post(array &$b)
|
||||||
{
|
{
|
||||||
if (!empty($_POST['diaspora-submit'])) {
|
if (!empty($_POST['diaspora-submit'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'post', intval($_POST['enabled']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'post' , intval($_POST['enabled']));
|
||||||
if (intval($_POST['enabled'])) {
|
if (intval($_POST['enabled'])) {
|
||||||
if (isset($_POST['handle'])) {
|
if (isset($_POST['handle'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'handle', trim($_POST['handle']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'handle' , trim($_POST['handle']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'password', trim($_POST['password']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'password' , trim($_POST['password']));
|
||||||
}
|
}
|
||||||
if (!empty($_POST['aspect'])) {
|
if (!empty($_POST['aspect'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'aspect', trim($_POST['aspect']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'aspect' , trim($_POST['aspect']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'diaspora', 'post_by_default', intval($_POST['post_by_default']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'diaspora', 'post_by_default', intval($_POST['post_by_default']));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'diaspora', 'password');
|
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'diaspora', 'password');
|
||||||
|
@ -145,10 +144,8 @@ function diaspora_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'] ?? '', 'diaspora') || ($post['parent'] != $post['id'])) {
|
||||||
!strstr($post['postopts'] ?? '', 'diaspora') || ($post['gravity'] != Item::GRAVITY_PARENT)
|
|
||||||
) {
|
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -156,19 +153,23 @@ 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['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
if ($b['private'] || $b['parent']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$diaspora_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post'));
|
$diaspora_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'diaspora','post'));
|
||||||
|
|
||||||
$diaspora_enable = (($diaspora_post && !empty($_REQUEST['diaspora_enable'])) ? intval($_REQUEST['diaspora_enable']) : 0);
|
$diaspora_enable = (($diaspora_post && !empty($_REQUEST['diaspora_enable'])) ? intval($_REQUEST['diaspora_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'diaspora', 'post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'diaspora','post_by_default'))) {
|
||||||
$diaspora_enable = 1;
|
$diaspora_enable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,11 +190,11 @@ function diaspora_send(array &$b)
|
||||||
|
|
||||||
Logger::notice('diaspora_send: invoked');
|
Logger::notice('diaspora_send: invoked');
|
||||||
|
|
||||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strstr($b['postopts'], 'diaspora')) {
|
if (!strstr($b['postopts'],'diaspora')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,9 +214,9 @@ function diaspora_send(array &$b)
|
||||||
|
|
||||||
Logger::info('diaspora_send: prepare posting');
|
Logger::info('diaspora_send: prepare posting');
|
||||||
|
|
||||||
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
|
$handle = DI::pConfig()->get($b['uid'],'diaspora','handle');
|
||||||
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
|
$password = DI::pConfig()->get($b['uid'],'diaspora','password');
|
||||||
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
|
$aspect = DI::pConfig()->get($b['uid'],'diaspora','aspect');
|
||||||
|
|
||||||
if ($handle && $password) {
|
if ($handle && $password) {
|
||||||
Logger::info('diaspora_send: all values seem to be okay');
|
Logger::info('diaspora_send: all values seem to be okay');
|
||||||
|
@ -229,7 +230,7 @@ function diaspora_send(array &$b)
|
||||||
// Removal of tags and mentions
|
// Removal of tags and mentions
|
||||||
// #-tags
|
// #-tags
|
||||||
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
||||||
// @-mentions
|
// @-mentions
|
||||||
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
||||||
|
|
||||||
// remove multiple newlines
|
// remove multiple newlines
|
||||||
|
@ -243,7 +244,7 @@ function diaspora_send(array &$b)
|
||||||
|
|
||||||
// Adding the title
|
// Adding the title
|
||||||
if (strlen($title)) {
|
if (strlen($title)) {
|
||||||
$body = "## " . html_entity_decode($title) . "\n\n" . $body;
|
$body = "## ".html_entity_decode($title)."\n\n".$body;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once "addon/diaspora/diasphp.php";
|
require_once "addon/diaspora/diasphp.php";
|
||||||
|
@ -251,9 +252,9 @@ function diaspora_send(array &$b)
|
||||||
try {
|
try {
|
||||||
Logger::info('diaspora_send: prepare');
|
Logger::info('diaspora_send: prepare');
|
||||||
$conn = new Diaspora_Connection($handle, $password);
|
$conn = new Diaspora_Connection($handle, $password);
|
||||||
Logger::info('diaspora_send: try to log in ' . $handle);
|
Logger::info('diaspora_send: try to log in '.$handle);
|
||||||
$conn->logIn();
|
$conn->logIn();
|
||||||
Logger::info('diaspora_send: try to send ' . $body);
|
Logger::info('diaspora_send: try to send '.$body);
|
||||||
|
|
||||||
$conn->provider = $hostname;
|
$conn->provider = $hostname;
|
||||||
$conn->postStatusMessage($body, $aspect);
|
$conn->postStatusMessage($body, $aspect);
|
||||||
|
@ -262,7 +263,7 @@ function diaspora_send(array &$b)
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
|
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
|
||||||
|
|
||||||
Logger::info('diaspora_send: requeueing ' . $b['uid']);
|
Logger::info('diaspora_send: requeueing '.$b['uid']);
|
||||||
|
|
||||||
Worker::defer();
|
Worker::defer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ 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;
|
||||||
|
@ -89,20 +88,24 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
if ($b['private'] || $b['parent']) {
|
||||||
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dw_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post'));
|
$dw_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post'));
|
||||||
|
|
||||||
$dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0);
|
$dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post_by_default'))) {
|
||||||
$dw_enable = 1;
|
$dw_enable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +122,7 @@ function dwpost_post_local(array &$b)
|
||||||
|
|
||||||
function dwpost_send(array &$b)
|
function dwpost_send(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,8 +145,8 @@ function dwpost_send(array &$b)
|
||||||
$user = User::getById($b['uid']);
|
$user = User::getById($b['uid']);
|
||||||
$tz = $user['timezone'] ?: 'UTC';
|
$tz = $user['timezone'] ?: 'UTC';
|
||||||
|
|
||||||
$dw_username = DI::pConfig()->get($b['uid'], 'dwpost', 'dw_username');
|
$dw_username = DI::pConfig()->get($b['uid'],'dwpost','dw_username');
|
||||||
$dw_password = DI::pConfig()->get($b['uid'], 'dwpost', 'dw_password');
|
$dw_password = DI::pConfig()->get($b['uid'],'dwpost','dw_password');
|
||||||
$dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc';
|
$dw_blog = 'http://www.dreamwidth.org/interface/xmlrpc';
|
||||||
|
|
||||||
if ($dw_username && $dw_password && $dw_blog) {
|
if ($dw_username && $dw_password && $dw_blog) {
|
||||||
|
@ -153,11 +156,11 @@ function dwpost_send(array &$b)
|
||||||
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
||||||
|
|
||||||
$date = DateTimeFormat::convert($b['created'], $tz);
|
$date = DateTimeFormat::convert($b['created'], $tz);
|
||||||
$year = intval(substr($date, 0, 4));
|
$year = intval(substr($date,0,4));
|
||||||
$mon = intval(substr($date, 5, 2));
|
$mon = intval(substr($date,5,2));
|
||||||
$day = intval(substr($date, 8, 2));
|
$day = intval(substr($date,8,2));
|
||||||
$hour = intval(substr($date, 11, 2));
|
$hour = intval(substr($date,11,2));
|
||||||
$min = intval(substr($date, 14, 2));
|
$min = intval(substr($date,14,2));
|
||||||
|
|
||||||
$xml = <<< EOT
|
$xml = <<< EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* 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;
|
||||||
|
|
|
@ -14,7 +14,6 @@ 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;
|
||||||
|
@ -86,12 +85,17 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
if ($b['private'] || $b['parent']) {
|
||||||
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +120,7 @@ function ijpost_post_local(array &$b)
|
||||||
|
|
||||||
function ijpost_send(array &$b)
|
function ijpost_send(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,11 +150,11 @@ function ijpost_send(array &$b)
|
||||||
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
||||||
|
|
||||||
$date = DateTimeFormat::convert($b['created'], $tz);
|
$date = DateTimeFormat::convert($b['created'], $tz);
|
||||||
$year = intval(substr($date, 0, 4));
|
$year = intval(substr($date,0,4));
|
||||||
$mon = intval(substr($date, 5, 2));
|
$mon = intval(substr($date,5,2));
|
||||||
$day = intval(substr($date, 8, 2));
|
$day = intval(substr($date,8,2));
|
||||||
$hour = intval(substr($date, 11, 2));
|
$hour = intval(substr($date,11,2));
|
||||||
$min = intval(substr($date, 14, 2));
|
$min = intval(substr($date,14,2));
|
||||||
|
|
||||||
$xml = <<< EOT
|
$xml = <<< EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
|
@ -13,7 +13,6 @@ 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()
|
||||||
|
@ -75,11 +74,13 @@ function libertree_settings(array &$data)
|
||||||
function libertree_settings_post(array &$b)
|
function libertree_settings_post(array &$b)
|
||||||
{
|
{
|
||||||
if (!empty($_POST['libertree-submit'])) {
|
if (!empty($_POST['libertree-submit'])) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'post', intval($_POST['libertree']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post',intval($_POST['libertree']));
|
||||||
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)
|
||||||
|
@ -90,10 +91,8 @@ function libertree_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'], 'libertree') || ($post['parent'] != $post['id'])) {
|
||||||
!strstr($post['postopts'], 'libertree') || ($post['gravity'] != Item::GRAVITY_PARENT)
|
|
||||||
) {
|
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -101,20 +100,26 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
if ($b['private'] || $b['parent']) {
|
||||||
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post'));
|
$ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post'));
|
||||||
|
|
||||||
$ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0);
|
$ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post_by_default'))) {
|
||||||
$ltree_enable = 1;
|
$ltree_enable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +138,11 @@ function libertree_send(array &$b)
|
||||||
{
|
{
|
||||||
Logger::notice('libertree_send: invoked');
|
Logger::notice('libertree_send: invoked');
|
||||||
|
|
||||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! strstr($b['postopts'], 'libertree')) {
|
if (! strstr($b['postopts'],'libertree')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,15 +159,15 @@ function libertree_send(array &$b)
|
||||||
|
|
||||||
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
|
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
|
||||||
|
|
||||||
$ltree_api_token = DI::pConfig()->get($b['uid'], 'libertree', 'libertree_api_token');
|
$ltree_api_token = DI::pConfig()->get($b['uid'],'libertree','libertree_api_token');
|
||||||
$ltree_url = DI::pConfig()->get($b['uid'], 'libertree', 'libertree_url');
|
$ltree_url = DI::pConfig()->get($b['uid'],'libertree','libertree_url');
|
||||||
$ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token";
|
$ltree_blog = "$ltree_url/api/v1/posts/create/?token=$ltree_api_token";
|
||||||
$ltree_source = DI::baseUrl()->getHost();
|
$ltree_source = DI::baseUrl()->getHost();
|
||||||
|
|
||||||
if ($b['app'] != "")
|
if ($b['app'] != "")
|
||||||
$ltree_source .= " (" . $b['app'] . ")";
|
$ltree_source .= " (".$b['app'].")";
|
||||||
|
|
||||||
if ($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) {
|
if($ltree_url && $ltree_api_token && $ltree_blog && $ltree_source) {
|
||||||
$title = $b['title'];
|
$title = $b['title'];
|
||||||
$body = $b['body'];
|
$body = $b['body'];
|
||||||
// Insert a newline before and after a quote
|
// Insert a newline before and after a quote
|
||||||
|
@ -172,7 +177,7 @@ function libertree_send(array &$b)
|
||||||
// Removal of tags and mentions
|
// Removal of tags and mentions
|
||||||
// #-tags
|
// #-tags
|
||||||
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
$body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
|
||||||
// @-mentions
|
// @-mentions
|
||||||
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
$body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
|
||||||
|
|
||||||
// remove multiple newlines
|
// remove multiple newlines
|
||||||
|
@ -193,7 +198,7 @@ function libertree_send(array &$b)
|
||||||
$params = [
|
$params = [
|
||||||
'text' => $body,
|
'text' => $body,
|
||||||
'source' => $ltree_source
|
'source' => $ltree_source
|
||||||
// 'token' => $ltree_api_token
|
// 'token' => $ltree_api_token
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
|
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
|
||||||
|
|
|
@ -14,7 +14,6 @@ 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;
|
||||||
|
@ -36,7 +35,7 @@ function ljpost_jot_nets(array &$jotnets_fields)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post')) {
|
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post')) {
|
||||||
$jotnets_fields[] = [
|
$jotnets_fields[] = [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'field' => [
|
'field' => [
|
||||||
|
@ -58,7 +57,7 @@ function ljpost_settings(array &$data)
|
||||||
$ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'ij_username');
|
$ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'ij_username');
|
||||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default');
|
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default');
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
$t= Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
||||||
$html = Renderer::replaceMacros($t, [
|
$html = Renderer::replaceMacros($t, [
|
||||||
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
|
'$enabled' => ['ljpost', DI::l10n()->t('Enable LiveJournal Post Addon'), $enabled],
|
||||||
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
|
'$username' => ['ij_username', DI::l10n()->t('LiveJournal username'), $ij_username],
|
||||||
|
@ -87,16 +86,20 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
if ($b['private'] || $b['parent']) {
|
||||||
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$lj_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post'));
|
$lj_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post'));
|
||||||
$lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0);
|
$lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0);
|
||||||
|
|
||||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'))) {
|
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'))) {
|
||||||
|
@ -115,11 +118,11 @@ function ljpost_post_local(array &$b)
|
||||||
|
|
||||||
function ljpost_send(array &$b)
|
function ljpost_send(array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strstr($b['postopts'], 'ljpost')) {
|
if (!strstr($b['postopts'],'ljpost')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +139,13 @@ function ljpost_send(array &$b)
|
||||||
$user = User::getById($b['uid']);
|
$user = User::getById($b['uid']);
|
||||||
$tz = $user['timezone'] ?: 'UTC';
|
$tz = $user['timezone'] ?: 'UTC';
|
||||||
|
|
||||||
$lj_username = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_username'));
|
$lj_username = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_username'));
|
||||||
$lj_password = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_password'));
|
$lj_password = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_password'));
|
||||||
$lj_journal = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_journal'));
|
$lj_journal = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_journal'));
|
||||||
// if(! $lj_journal)
|
// if(! $lj_journal)
|
||||||
// $lj_journal = $lj_username;
|
// $lj_journal = $lj_username;
|
||||||
|
|
||||||
$lj_blog = XML::escape(DI::pConfig()->get($b['uid'], 'ljpost', 'lj_blog'));
|
$lj_blog = XML::escape(DI::pConfig()->get($b['uid'],'ljpost','lj_blog'));
|
||||||
if (!strlen($lj_blog)) {
|
if (!strlen($lj_blog)) {
|
||||||
$lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc');
|
$lj_blog = XML::escape('http://www.livejournal.com/interface/xmlrpc');
|
||||||
}
|
}
|
||||||
|
@ -154,11 +157,11 @@ function ljpost_send(array &$b)
|
||||||
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
$tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
|
||||||
|
|
||||||
$date = DateTimeFormat::convert($b['created'], $tz);
|
$date = DateTimeFormat::convert($b['created'], $tz);
|
||||||
$year = intval(substr($date, 0, 4));
|
$year = intval(substr($date,0,4));
|
||||||
$mon = intval(substr($date, 5, 2));
|
$mon = intval(substr($date,5,2));
|
||||||
$day = intval(substr($date, 8, 2));
|
$day = intval(substr($date,8,2));
|
||||||
$hour = intval(substr($date, 11, 2));
|
$hour = intval(substr($date,11,2));
|
||||||
$min = intval(substr($date, 14, 2));
|
$min = intval(substr($date,14,2));
|
||||||
|
|
||||||
$xml = <<< EOT
|
$xml = <<< EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
|
@ -18,7 +18,6 @@ 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;
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ function pnut_connect()
|
||||||
$o = DI::l10n()->t('Error fetching token. Please try again.', ['code' => $e->getCode(), 'message' => $e->getMessage()]);
|
$o = DI::l10n()->t('Error fetching token. Please try again.', ['code' => $e->getCode(), 'message' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page") . '</a>';
|
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t("return to the connector page").'</a>';
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +119,7 @@ function pnut_settings(array &$data)
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirectUri = DI::baseUrl() . '/pnut/connect';
|
$redirectUri = DI::baseUrl() . '/pnut/connect';
|
||||||
$scope = ['write_post', 'files'];
|
$scope = ['write_post','files'];
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post') ?? false;
|
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post') ?? false;
|
||||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default') ?? false;
|
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pnut', 'post_by_default') ?? false;
|
||||||
|
@ -222,7 +221,7 @@ function pnut_hook_fork(array &$b)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
|
if (!strstr($post['postopts'] ?? '', 'pnut') || ($post['parent'] != $post['id']) || $post['private']) {
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -230,11 +229,15 @@ 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['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
if ($b['private'] || $b['parent']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +265,7 @@ function pnut_post_hook(array &$b)
|
||||||
/**
|
/**
|
||||||
* Post to pnut.io
|
* Post to pnut.io
|
||||||
*/
|
*/
|
||||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
|
if (($post['parent'] != $post['id']) && !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['gravity'] != Item::GRAVITY_PARENT)|| ($post['private'] == Item::PRIVATE)) {
|
if (!strstr($post['postopts'], 'pumpio') || ($post['parent'] != $post['id']) || $post['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'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
|
if (!count($receiver) && ($b['private'] || !strstr($b['postopts'], 'pumpio'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1319,7 +1319,7 @@ function pumpio_getreceiver(array $b)
|
||||||
{
|
{
|
||||||
$receiver = [];
|
$receiver = [];
|
||||||
|
|
||||||
if ($b['private'] != Item::PRIVATE) {
|
if (!$b['private']) {
|
||||||
if (!strstr($b['postopts'], 'pumpio')) {
|
if (!strstr($b['postopts'], 'pumpio')) {
|
||||||
return $receiver;
|
return $receiver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
|
if ($post['deleted'] || ($post['created'] !== $post['edited']) || strpos($post['postopts'] ?? '', 'statusnet') === false || ($post['parent'] != $post['id']) || $post['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'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,13 +439,11 @@ 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 (
|
if ($sitename != '' &&
|
||||||
$sitename != '' &&
|
|
||||||
$apiurl != '' &&
|
$apiurl != '' &&
|
||||||
$secret != '' &&
|
$secret != '' &&
|
||||||
$key != '' &&
|
$key != '' &&
|
||||||
empty($_POST['delete'][$id])
|
empty($_POST['delete'][$id])) {
|
||||||
) {
|
|
||||||
|
|
||||||
$sites[] = [
|
$sites[] = [
|
||||||
'sitename' => $sitename,
|
'sitename' => $sitename,
|
||||||
|
|
|
@ -22,7 +22,6 @@ 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;
|
||||||
|
@ -32,6 +31,7 @@ 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['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) {
|
if (($post['parent'] != $post['id']) && !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['gravity'] != Item::GRAVITY_PARENT) || ($post['private'] == Item::PRIVATE)) {
|
} elseif (!strstr($post['postopts'] ?? '', 'tumblr') || ($post['parent'] != $post['id']) || $post['private']) {
|
||||||
DI::logger()->info('Post will not be exported', ['uid' => $post['uid'], 'postopts' => $post['postopts'], 'gravity' => $post['gravity'], 'private' => $post['private']]);
|
DI::logger()->info('Activities are never exported when we don\'t import the tumblr timeline', ['uid' => $post['uid']]);
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -491,11 +491,15 @@ 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['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
if ($b['private'] || $b['parent']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +575,7 @@ function tumblr_send(array &$b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} elseif (($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'tumblr')) {
|
} elseif ($b['private'] || !strstr($b['postopts'], 'tumblr')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,7 +850,6 @@ 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,
|
||||||
|
|
|
@ -170,7 +170,7 @@ function twitter_hook_fork(array &$b)
|
||||||
$post = $b['data'];
|
$post = $b['data'];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
|
$post['deleted'] || $post['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'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
if ($b['edit'] || $b['private'] || $b['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'] == Item::PRIVATE) || $b['deleted'] || ($b['created'] !== $b['edited'])) {
|
if (($b['gravity'] != Item::GRAVITY_PARENT) || !strstr($b['postopts'], 'twitter') || $b['private'] || $b['deleted'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,8 +108,8 @@ function wppost_hook_fork(array &$b)
|
||||||
$post = $b['data'];
|
$post = $b['data'];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$post['deleted'] || ($post['private'] == Item::PRIVATE) || ($post['created'] !== $post['edited']) ||
|
$post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
|
||||||
!strstr($post['postopts'] ?? '', 'wppost') || ($post['gravity'] != Item::GRAVITY_PARENT)
|
!strstr($post['postopts'] ?? '', 'wppost') || ($post['parent'] != $post['id'])
|
||||||
) {
|
) {
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
|
@ -118,12 +118,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
if ($b['private'] || $b['parent']) {
|
||||||
if ($b['edit'] || ($b['private'] == Item::PRIVATE) || ($b['gravity'] != Item::GRAVITY_PARENT)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,9 +152,12 @@ 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'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue