use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
use Friendica\Core\Hook;
+use Friendica\Core\L10n;
use Friendica\Core\Lock;
use Friendica\Core\Logger;
-use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
-use Friendica\Util\XML;
+use Friendica\Util\Network;
use Friendica\Util\Security;
use Friendica\Util\Strings;
-use Friendica\Util\Network;
+use Friendica\Util\XML;
+use Friendica\Worker\Delivery;
use Text_LanguageDetect;
class Item extends BaseObject
// Field list that is used to deliver items via the protocols
const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid',
- 'created', 'edited', 'verb', 'object-type', 'object', 'target',
+ 'parent-guid', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
'private', 'title', 'body', 'location', 'coord', 'app',
'attach', 'tag', 'deleted', 'extid', 'post-type',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network',
'title', 'content-warning', 'body', 'location', 'coord', 'app',
'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target',
- 'author-id', 'author-link', 'author-name', 'author-avatar',
+ 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
'owner-id', 'owner-link', 'owner-name', 'owner-avatar'];
// Never reorder or remove entries from this list. Just add new ones at the end, if needed.
// We only need to notfiy others when it is an original entry from us.
// Only call the notifier when the item has some content relevant change.
if ($item['origin'] && in_array('edited', array_keys($fields))) {
- Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $item['id']);
+ Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $item['id']);
}
}
self::delete(['uri' => $item['uri'], 'deleted' => false], $priority);
// send the notification upstream/downstream
- Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", intval($item['id']));
+ Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id']));
} elseif ($item['uid'] != 0) {
// When we delete just our local user copy of an item, we have to set a marker to hide it
return 0;
}
+ if (!empty($uid) && Contact::isBlockedByUser($item['author-link'], $uid)) {
+ Logger::notice('Author is blocked by user', ['author-link' => $item['author-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
+ return 0;
+ }
+
+ if (!empty($uid) && ($item['parent-uri'] === $item['uri']) && Contact::isIgnoredByUser($item['author-link'], $uid)) {
+ Logger::notice('Author is ignored by user', ['author-link' => $item['author-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
+ return 0;
+ }
+
$default = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
'photo' => $item['owner-avatar'], 'network' => $item['network']];
return 0;
}
+ if (!empty($uid) && Contact::isBlockedByUser($item['owner-link'], $uid)) {
+ Logger::notice('Owner is blocked by user', ['owner-link' => $item['owner-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
+ return 0;
+ }
+
+ if (!empty($uid) && ($item['parent-uri'] === $item['uri']) && Contact::isIgnoredByUser($item['owner-link'], $uid)) {
+ Logger::notice('Owner is ignored by user', ['owner-link' => $item['owner-link'], 'uid' => $uid, 'item-uri' => $item['uri']]);
+ return 0;
+ }
+
if ($item['network'] == Protocol::PHANTOM) {
$item['network'] = Protocol::DFRN;
Logger::notice('Missing network, setting to {network}.', [
$item['thr-parent'] = $item['parent-uri'];
- $notify_type = '';
+ $notify_type = Delivery::POST;
$allow_cid = '';
$allow_gid = '';
$deny_cid = '';
$allow_gid = $item['allow_gid'];
$deny_cid = $item['deny_cid'];
$deny_gid = $item['deny_gid'];
- $notify_type = 'wall-new';
} else {
// find the parent and snarf the item id and ACLs
// and anything else we need to inherit
$allow_gid = $parent['allow_gid'];
$deny_cid = $parent['deny_cid'];
$deny_gid = $parent['deny_gid'];
- $item['wall'] = $parent['wall'];
- $notify_type = 'comment-new';
+ $item['wall'] = $parent['wall'];
/*
* If the parent is private, force privacy for the entire conversation
}
}
+ if (stristr($item['verb'], ACTIVITY_POKE)) {
+ $notify_type = Delivery::POKE;
+ }
+
$item['parent-uri-id'] = ItemURI::getIdByURI($item['parent-uri']);
$item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']);
unset($item['author-link']);
unset($item['author-name']);
unset($item['author-avatar']);
+ unset($item['author-network']);
unset($item['owner-link']);
unset($item['owner-name']);
check_user_notification($current_post);
- if ($notify) {
+ if ($notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin']))) {
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
- } elseif ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin'])) {
- if ($item['gravity'] == GRAVITY_ACTIVITY) {
- $cmd = $item['origin'] ? 'activity-new' : 'activity-import';
- } elseif ($item['gravity'] == GRAVITY_COMMENT) {
- $cmd = $item['origin'] ? 'comment-new' : 'comment-import';
- } else {
- $cmd = 'wall-new';
- }
-
- Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $cmd, $current_post);
}
return $current_post;
self::updateThread($item_id);
- Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', 'tgroup', $item_id);
+ Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', Delivery::POST, $item_id);
}
public static function isRemoteSelf($contact, &$datarray)
$datarray['author-link'] = $datarray['owner-link'];
$datarray['author-avatar'] = $datarray['owner-avatar'];
- unset($datarray['created']);
unset($datarray['edited']);
unset($datarray['network']);