*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
'$l10n' => [
- '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.'),
- 'collapseAuthor' => $l10n->t('Collapse this author\'s posts?'),
+ '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."),
+ 'collapseAuthor' => $l10n->t("Collapse this author's posts?"),
+ 'ignoreServer' => $l10n->t("Ignore this author's server?"),
+ 'ignoreServerDesc' => $l10n->t("You won't see any content from this server including reshares in your Network page, the community pages and individual conversations."),
'likeError' => $l10n->t('Like not successful'),
'dislikeError' => $l10n->t('Dislike not successful'),
'received' => $item['received'],
'created_date' => $item['created'],
'uriid' => $item['uri-id'],
+ 'author_gsid' => $item['author-gsid'],
'network' => $item['network'],
'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network'], $item['author-gsid']),
'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link'], $item['author-gsid']),
--- /dev/null
+<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Module\Settings\Server;
+
+use Friendica\App;
+use Friendica\Core\L10n;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
+use Friendica\Core\System;
+use Friendica\Module\Response;
+use Friendica\Network\HTTPException\BadRequestException;
+use Friendica\User\Settings\Repository\UserGServer;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
+
+class Action extends \Friendica\BaseModule
+{
+ /** @var IHandleUserSessions */
+ private $session;
+ /** @var UserGServer */
+ private $repository;
+
+ public function __construct(UserGServer $repository, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ {
+ parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
+
+ $this->session = $session;
+ $this->repository = $repository;
+ }
+
+ public function post(array $request = [])
+ {
+ $userGServer = $this->repository->getOneByUserAndServer($this->session->getLocalUserId(), $this->parameters['gsid']);
+
+ switch ($this->parameters['action']) {
+ case 'ignore':
+ $userGServer->ignore();
+ break;
+ case 'unignore':
+ $userGServer->unignore();
+ break;
+ default:
+ throw new BadRequestException('Unknown user server action ' . $this->parameters['action']);
+ }
+
+ $this->repository->save($userGServer);
+
+ System::exit();
+ }
+}
use Friendica\Protocol\Activity;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Network;
use Friendica\Util\Proxy;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
$pinned = DI::l10n()->t('Pinned item');
}
- $drop = false;
- $block = false;
- $ignore = false;
- $collapse = false;
- $report = false;
+ $drop = false;
+ $block = false;
+ $ignore = false;
+ $collapse = false;
+ $report = false;
+ $ignoreServer = false;
if (DI::userSession()->getLocalUserId()) {
$drop = [
'dropping' => $dropping,
'label' => DI::l10n()->t('Report post'),
'href' => 'moderation/report/create?' . http_build_query(['cid' => $item['author-id'], 'uri-ids' => [$item['uri-id']]]),
];
+ if (!Network::isLocalLink($item['plink'])) {
+ $ignoreServer = [
+ 'label' => DI::l10n()->t("Ignore %s's server", $item['author-name']),
+ ];
+ }
}
$filer = DI::userSession()->getLocalUserId() ? DI::l10n()->t('Save to folder') : false;
'ignore_author' => $ignore,
'collapse' => $collapse,
'report' => $report,
+ 'ignore_server' => $ignoreServer,
'vote' => $buttons,
'like_html' => $responses['like']['output'],
'dislike_html' => $responses['dislike']['output'],
'wait' => DI::l10n()->t('Please wait'),
'thread_level' => $thread_level,
'edited' => $edited,
+ 'author_gsid' => $item['author-gsid'],
'network' => $item['network'],
'network_name' => ContactSelector::networkToName($item['author-network'], $item['author-link'], $item['network'], $item['author-gsid']),
'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link'], $item['author-gsid']),
$this->ignored = $ignored;
$this->gserver = $gserver;
}
+
+ /**
+ * Toggle the ignored property.
+ *
+ * Chainable.
+ *
+ * @return $this
+ */
+ public function toggleIgnored(): UserGServer
+ {
+ $this->ignored = !$this->ignored;
+
+ return $this;
+ }
+
+ /**
+ * Set the ignored property.
+ *
+ * Chainable.
+ *
+ * @return $this
+ */
+ public function ignore(): UserGServer
+ {
+ $this->ignored = true;
+
+ return $this;
+ }
+
+ /**
+ * Unset the ignored property.
+ *
+ * Chainable.
+ *
+ * @return $this
+ */
+ public function unignore(): UserGServer
+ {
+ $this->ignored = false;
+
+ return $this;
+ }
}
],
'/settings' => [
+ '/server' => [
+ '/{gsid:\d+}/{action}' => [Module\Settings\Server\Action::class, [ R::POST]],
+ ],
'[/]' => [Module\Settings\Account::class, [R::GET, R::POST]],
'/account' => [
'[/]' => [Module\Settings\Account::class, [R::GET, R::POST]],
return confirm(aStr.collapseAuthor);
}
+function confirmIgnoreServer() {
+ return confirm(aStr.ignoreServer + "\n" + aStr.ignoreServerDesc);
+}
+
/**
* Hide and removes an item element from the DOM after the deletion url is
* successful, restore it else.
});
}
}
+
+
+/**
+ * Ignore author server
+ *
+ * @param {string} url The server ignore URL
+ * @param {string} elementId The DOM id of the item element
+ * @returns {undefined}
+ */
+function ignoreServer(url, elementId) {
+ if (confirmIgnoreServer()) {
+ $("body").css("cursor", "wait");
+
+ var $el = $(document.getElementById(elementId));
+
+ $el.fadeTo("fast", 0.33, function () {
+ $.post(url)
+ .then(function () {
+ $el.remove();
+ })
+ .fail(function () {
+ // @todo Show related error message
+ $el.fadeTo("fast", 1);
+ })
+ .always(function () {
+ $("body").css("cursor", "auto");
+ });
+ });
+ }
+}
// @license-end
They are loaded into the html <head> so that js functions can use them *}}
<script type="text/javascript">
const aStr = {
- delitem : "{{$l10n.delitem|escape:'javascript' nofilter}}",
- blockAuthor : "{{$l10n.blockAuthor|escape:'javascript' nofilter}}",
- ignoreAuthor : "{{$l10n.ignoreAuthor|escape:'javascript' nofilter}}",
- collapseAuthor : "{{$l10n.collapseAuthor|escape:'javascript' nofilter}}",
+ delitem : "{{$l10n.delitem|escape:'javascript' nofilter}}",
+ blockAuthor : "{{$l10n.blockAuthor|escape:'javascript' nofilter}}",
+ ignoreAuthor : "{{$l10n.ignoreAuthor|escape:'javascript' nofilter}}",
+ collapseAuthor : "{{$l10n.collapseAuthor|escape:'javascript' nofilter}}",
+ ignoreServer : "{{$l10n.ignoreServer|escape:'javascript' nofilter}}",
+ ignoreServerDesc : "{{$l10n.ignoreServerDesc|escape:'javascript' nofilter}}",
};
const aActErr = {
like : "{{$l10n.likeError|escape:'javascript' nofilter}}",
{{/if}}
{{if $item.ignore_author}}
<li role="menuitem">
- <a class="btn-link navicon ignore" href="javascript:ignoreAuthor('item/ignore/{{$item.id}}', 'item-{{$item.guid}}');" title="{{$item.ignore_author.label}}"><i class="fa fa-ban" aria-hidden="true"></i> {{$item.ignore_author.label}}</a>
+ <a class="btn-link navicon ignore" href="javascript:ignoreAuthor('item/ignore/{{$item.id}}', 'item-{{$item.guid}}');" title="{{$item.ignore_author.label}}"><i class="fa fa-eye-slash" aria-hidden="true"></i> {{$item.ignore_author.label}}</a>
</li>
{{/if}}
{{if $item.collapse}}
<li role="menuitem">
- <a class="btn-link navicon collapse" href="javascript:collapseAuthor('item/collapse/{{$item.id}}', 'item-{{$item.guid}}');" title="{{$item.collapse.label}}"><i class="fa fa-ban" aria-hidden="true"></i> {{$item.collapse.label}}</a>
+ <a class="btn-link navicon collapse" href="javascript:collapseAuthor('item/collapse/{{$item.id}}', 'item-{{$item.guid}}');" title="{{$item.collapse.label}}"><i class="fa fa-minus-square" aria-hidden="true"></i> {{$item.collapse.label}}</a>
</li>
+ {{/if}}
+ {{if $item.ignore_server}}
+ <li role="menuitem">
+ <a class="btn-link navicon ignoreServer" href="javascript:ignoreServer('settings/server/{{$item.author_gsid}}/ignore', 'item-{{$item.guid}}');" title="{{$item.ignore_server.label}}"><i class="fa fa-eye-slash" aria-hidden="true"></i> {{$item.ignore_server.label}}</a>
</li>
{{/if}}
{{if $item.report}}