Contact\User::setBlocked($item['author-id'], DI::userSession()->getLocalUserId(), true);
+ if (DI::mode()->isAjax()) {
+ // ajax return: [<item id>, 0 (no perm) | <owner id>]
+ System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
+ } else {
+ item_redirect_after_action($item, $args->get(3));
+ }
+ break;
+
+ case 'ignore':
+ $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
+ if (empty($item['author-id'])) {
+ throw new HTTPException\NotFoundException('Item not found');
+ }
+
+ Contact\User::setIgnored($item['author-id'], DI::userSession()->getLocalUserId(), true);
+
if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$delitem' => $l10n->t('Delete this item?'),
'$blockAuthor' => $l10n->t('Block this author? They won\'t be able to follow you nor see your public posts, and you won\'t be able to see their posts and their notifications.'),
+ '$ignoreAuthor' => $l10n->t('Ignore this author? You won\'t be able to see their posts and their notifications.'),
'$update_interval' => $interval,
'$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon,
$transmit = $notify || ($posted_item['visible'] && ($parent_origin || $posted_item['origin']));
if ($transmit) {
+ if ($posted_item['uid'] && Contact\User::isBlocked($posted_item['author-id'], $posted_item['uid'])) {
+ Logger::info('Message from blocked author will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['author-id']]);
+ $transmit = false;
+ }
+ if ($transmit && $posted_item['uid'] && Contact\User::isBlocked($posted_item['owner-id'], $posted_item['uid'])) {
+ Logger::info('Message from blocked owner will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['owner-id']]);
+ $transmit = false;
+ }
+ if ($transmit && !empty($posted_item['causer-id']) && $posted_item['uid'] && Contact\User::isBlocked($posted_item['causer-id'], $posted_item['uid'])) {
+ Logger::info('Message from blocked causer will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'cid' => $posted_item['causer-id']]);
+ $transmit = false;
+ }
+
// Don't relay participation messages
if (($posted_item['verb'] == Activity::FOLLOW) &&
(!$posted_item['origin'] || ($posted_item['author-id'] != Contact::getPublicIdByUserId($uid)))) {
return false;
}
- if (!empty($item['causer-id']) && ($item['gravity'] === self::GRAVITY_PARENT) && Contact\User::isIgnored($item['causer-id'], $user_id)) {
+ if (!empty($item['author-id']) && Contact\User::isIgnored($item['author-id'], $user_id)) {
+ Logger::notice('Author is ignored by user', ['author-link' => $item['author-link'], 'uid' => $user_id, 'item-uri' => $item['uri']]);
+ return false;
+ }
+
+ if (!empty($item['owner-id']) && Contact\User::isIgnored($item['owner-id'], $user_id)) {
+ Logger::notice('Owner is ignored by user', ['owner-link' => $item['owner-link'], 'uid' => $user_id, 'item-uri' => $item['uri']]);
+ return false;
+ }
+
+ if (!empty($item['causer-id']) && Contact\User::isIgnored($item['causer-id'], $user_id)) {
Logger::notice('Causer is ignored by user', ['causer-link' => $item['causer-link'] ?? $item['causer-id'], 'uid' => $user_id, 'item-uri' => $item['uri']]);
return false;
}
AND NOT `author-blocked` AND NOT `owner-blocked`
AND (NOT `causer-blocked` OR `causer-id` = ? OR `causer-id` IS NULL) AND NOT `contact-blocked`
AND ((NOT `contact-readonly` AND NOT `contact-pending` AND (`contact-rel` IN (?, ?)))
- OR `self` OR `gravity` != ? OR `contact-uid` = ?)
+ OR `self` OR `contact-uid` = ?)
AND NOT `" . $view . "`.`uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `uid` = ? AND `hidden`)
AND NOT `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `blocked` AND `cid` = `author-id`)
AND NOT `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `blocked` AND `cid` = `owner-id`)
- AND NOT (`gravity` = ? AND `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored` AND `cid` = `author-id`))
- AND NOT (`gravity` = ? AND `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored` AND `cid` = `owner-id`))",
- 0, Contact::SHARING, Contact::FRIEND, Item::GRAVITY_PARENT, 0, $uid, $uid, $uid, Item::GRAVITY_PARENT, $uid, Item::GRAVITY_PARENT, $uid]);
+ AND NOT `author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored` AND `cid` = `author-id`)
+ AND NOT `owner-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `ignored` AND `cid` = `owner-id`)",
+ 0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid, $uid, $uid]);
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
public static function setNotification(int $uri_id, int $uid)
{
$fields = ['id', 'uri-id', 'parent-uri-id', 'uid', 'body', 'parent', 'gravity', 'vid', 'gravity',
- 'private', 'contact-id', 'thr-parent', 'thr-parent-id', 'parent-uri-id', 'parent-uri', 'author-id', 'verb'];
+ 'contact-id', 'author-id', 'owner-id', 'causer-id',
+ 'private', 'thr-parent', 'thr-parent-id', 'parent-uri-id', 'parent-uri', 'verb'];
$item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]);
if (!DBA::isResult($item)) {
return;
*/
private static function setNotificationForUser(array $item, int $uid)
{
+ if (Contact\User::isBlocked($item['author-id'], $uid) || Contact\User::isIgnored($item['author-id'], $uid) || Contact\User::isCollapsed($item['author-id'], $uid)) {
+ return;
+ }
+
+ if (Contact\User::isBlocked($item['owner-id'], $uid) || Contact\User::isIgnored($item['owner-id'], $uid) || Contact\User::isCollapsed($item['owner-id'], $uid)) {
+ return;
+ }
+
+ if (!empty($item['causer-id']) && (Contact\User::isBlocked($item['causer-id'], $uid) || Contact\User::isIgnored($item['causer-id'], $uid) || Contact\User::isCollapsed($item['causer-id'], $uid))) {
+ return;
+ }
+
if (Post\ThreadUser::getIgnored($item['parent-uri-id'], $uid)) {
return;
}
$pinned = '';
$pin = false;
$star = false;
- $ignore = false;
+ $ignore_thread = false;
$ispinned = 'unpinned';
$isstarred = 'unstarred';
$indent = '';
// Showing the one or the other text, depending upon if we can only hide it or really delete it.
$delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
- $drop = false;
- $block = false;
+ $drop = false;
+ $block = false;
+ $ignore = false;
if (DI::userSession()->getLocalUserId()) {
$drop = [
'dropping' => $dropping,
if (!$item['self'] && DI::userSession()->getLocalUserId()) {
$block = [
- 'blocking' => true,
- 'block' => DI::l10n()->t('Block %s', $item['author-name']),
- 'author_id' => $item['author-id'],
+ 'blocking' => true,
+ 'block' => DI::l10n()->t('Block %s', $item['author-name']),
+ 'author_id' => $item['author-id'],
+ ];
+ $ignore = [
+ 'ignoring' => true,
+ 'ignore' => DI::l10n()->t('Ignore %s', $item['author-name']),
+ 'author_id' => $item['author-id'],
];
}
if ($this->isToplevel()) {
if (DI::userSession()->getLocalUserId()) {
- $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
- if ($item['mention'] || $ignored) {
- $ignore = [
+ $ignored_thread = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
+ if ($item['mention'] || $ignored_thread) {
+ $ignore_thread = [
'do' => DI::l10n()->t('Ignore thread'),
'undo' => DI::l10n()->t('Unignore thread'),
'toggle' => DI::l10n()->t('Toggle ignore status'),
- 'classdo' => $ignored ? 'hidden' : '',
- 'classundo' => $ignored ? '' : 'hidden',
+ 'classdo' => $ignored_thread ? 'hidden' : '',
+ 'classundo' => $ignored_thread ? '' : 'hidden',
'ignored' => DI::l10n()->t('Ignored'),
];
}
'pinned' => $pinned,
'isstarred' => $isstarred,
'star' => $star,
- 'ignore' => $ignore,
+ 'ignore' => $ignore_thread,
'tagger' => $tagger,
'filer' => $filer,
'language' => $languages,
'drop' => $drop,
'block' => $block,
+ 'ignore_author' => $ignore,
'vote' => $buttons,
'like_html' => $responses['like']['output'],
'dislike_html' => $responses['dislike']['output'],
return confirm(aStr.blockAuthor);
}
+function confirmIgnore() {
+ return confirm(aStr.ignoreAuthor);
+}
+
/**
* Hide and removes an item element from the DOM after the deletion url is
* successful, restore it else.
});
}
}
+
+/**
+ * Ignored an author and hide and removes an item element from the DOM after the block is
+ * successful, restore it else.
+ *
+ * @param {string} url The item removal URL
+ * @param {string} elementId The DOM id of the item element
+ * @returns {undefined}
+ */
+function ignoreAuthor(url, elementId) {
+ if (confirmIgnore()) {
+ $("body").css("cursor", "wait");
+
+ var $el = $(document.getElementById(elementId));
+
+ $el.fadeTo("fast", 0.33, function () {
+ $.get(url)
+ .then(function () {
+ $el.remove();
+ })
+ .fail(function () {
+ // @todo Show related error message
+ $el.show();
+ })
+ .always(function () {
+ $("body").css("cursor", "auto");
+ });
+ });
+ }
+}
// @license-end
var localUser = {{if $local_user}}{{$local_user}}{{else}}false{{/if}};
var aStr = {
- 'delitem' : "{{$delitem|escape:'javascript' nofilter}}",
- 'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}",
+ 'delitem' : "{{$delitem|escape:'javascript' nofilter}}",
+ 'blockAuthor' : "{{$blockAuthor|escape:'javascript' nofilter}}",
+ 'ignoreAuthor' : "{{$ignoreAuthor|escape:'javascript' nofilter}}",
};
</script>
<a class="btn-link navicon block" href="javascript:blockAuthor('item/block/{{$item.id}}/{{$item.return}}', 'item-{{$item.guid}}');" title="{{$item.block.block}}"><i class="fa fa-ban" aria-hidden="true"></i> {{$item.block.block}}</a>
</li>
{{/if}}
- </ul>
+ {{if $item.ignore_author}}
+ <li role="menuitem">
+ <a class="btn-link navicon ignore" href="javascript:ignoreAuthor('item/ignore/{{$item.id}}/{{$item.return}}', 'item-{{$item.guid}}');" title="{{$item.ignore_author.ignore}}"><i class="fa fa-ban" aria-hidden="true"></i> {{$item.ignore_author.ignore}}</a>
+ </li>
+ {{/if}}
+ </ul>
<img id="like-rotator-{{$item.id}}" class="like-rotator" src="images/rotator.gif" alt="{{$item.wait}}" title="{{$item.wait}}" style="display: none;" />
</span>
{{else}}