mirror of
https://github.com/friendica/friendica
synced 2025-04-27 15:50:12 +00:00
[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
|
@ -245,10 +245,12 @@ 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?'),
|
||||
'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'),
|
||||
|
|
|
@ -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;
|
||||
|
@ -248,11 +249,12 @@ class Post
|
|||
$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,
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue