[frio] Add Mute Author Server button to post actions
This commit is contained in:
parent
9bbb55b2bb
commit
4c6334ea13
9 changed files with 180 additions and 15 deletions
|
@ -246,9 +246,11 @@ class Page implements ArrayAccess
|
|||
$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?'),
|
||||
'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'),
|
||||
|
|
|
@ -1462,6 +1462,7 @@ class Conversation
|
|||
'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']),
|
||||
|
|
68
src/Module/Settings/Server/Action.php
Normal file
68
src/Module/Settings/Server/Action.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?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();
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ use Friendica\Model\User;
|
|||
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;
|
||||
|
@ -253,6 +254,7 @@ class Post
|
|||
$ignore = false;
|
||||
$collapse = false;
|
||||
$report = false;
|
||||
$ignoreServer = false;
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$drop = [
|
||||
'dropping' => $dropping,
|
||||
|
@ -282,6 +284,11 @@ class Post
|
|||
'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;
|
||||
|
@ -557,6 +564,7 @@ class Post
|
|||
'ignore_author' => $ignore,
|
||||
'collapse' => $collapse,
|
||||
'report' => $report,
|
||||
'ignore_server' => $ignoreServer,
|
||||
'vote' => $buttons,
|
||||
'like_html' => $responses['like']['output'],
|
||||
'dislike_html' => $responses['dislike']['output'],
|
||||
|
@ -571,6 +579,7 @@ class Post
|
|||
'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']),
|
||||
|
|
|
@ -47,4 +47,46 @@ class UserGServer extends \Friendica\BaseEntity
|
|||
$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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -639,6 +639,9 @@ return [
|
|||
],
|
||||
|
||||
'/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]],
|
||||
|
|
|
@ -210,6 +210,10 @@ function confirmCollapse() {
|
|||
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.
|
||||
|
@ -325,4 +329,34 @@ function collapseAuthor(url, elementId) {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -7,6 +7,8 @@ They are loaded into the html <head> so that js functions can use them *}}
|
|||
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}}",
|
||||
|
|
|
@ -401,13 +401,17 @@ as the value of $top_child_total (this is done at the end of this file)
|
|||
{{/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}}
|
||||
|
|
Loading…
Reference in a new issue