Merge pull request #13798 from annando/unkmail2

The "unkmail" functionality is removed
This commit is contained in:
Hypolite Petovan 2024-01-03 10:02:31 -05:00 committed by GitHub
commit 4132e7a468
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 190 additions and 477 deletions

View File

@ -73,8 +73,6 @@ CREATE TABLE IF NOT EXISTS `user` (
`blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user', `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user',
`hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unknown viewers', `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unknown viewers',
`blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user', `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user',
`unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user',
`cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '',
`notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options', `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options',
`page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type', `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type',
`account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '',
@ -2967,8 +2965,6 @@ CREATE VIEW `owner-view` AS SELECT
`user`.`blockwall` AS `blockwall`, `user`.`blockwall` AS `blockwall`,
`user`.`hidewall` AS `hidewall`, `user`.`hidewall` AS `hidewall`,
`user`.`blocktags` AS `blocktags`, `user`.`blocktags` AS `blocktags`,
`user`.`unkmail` AS `unkmail`,
`user`.`cntunkmail` AS `cntunkmail`,
`user`.`notify-flags` AS `notify-flags`, `user`.`notify-flags` AS `notify-flags`,
`user`.`page-flags` AS `page-flags`, `user`.`page-flags` AS `page-flags`,
`user`.`account-type` AS `account-type`, `user`.`account-type` AS `account-type`,

View File

@ -34,8 +34,6 @@ Fields
| blockwall | Prohibit contacts to post to the profile page of the user | boolean | NO | | 0 | | | blockwall | Prohibit contacts to post to the profile page of the user | boolean | NO | | 0 | |
| hidewall | Hide profile details from unknown viewers | boolean | NO | | 0 | | | hidewall | Hide profile details from unknown viewers | boolean | NO | | 0 | |
| blocktags | Prohibit contacts to tag the post of this user | boolean | NO | | 0 | | | blocktags | Prohibit contacts to tag the post of this user | boolean | NO | | 0 | |
| unkmail | Permit unknown people to send private mails to this user | boolean | NO | | 0 | |
| cntunkmail | | int unsigned | NO | | 10 | |
| notify-flags | email notification options | smallint unsigned | NO | | 65535 | | | notify-flags | email notification options | smallint unsigned | NO | | 65535 | |
| page-flags | page/profile type | tinyint unsigned | NO | | 0 | | | page-flags | page/profile type | tinyint unsigned | NO | | 0 | |
| account-type | | tinyint unsigned | NO | | 0 | | | account-type | | tinyint unsigned | NO | | 0 | |

View File

@ -352,8 +352,6 @@ class Profile
if (Contact::canReceivePrivateMessages($profile_contact)) { if (Contact::canReceivePrivateMessages($profile_contact)) {
if ($visitor_is_followed || $visitor_is_following) { if ($visitor_is_followed || $visitor_is_following) {
$wallmessage_link = $visitor_base_path . '/message/new/' . $profile_contact['id']; $wallmessage_link = $visitor_base_path . '/message/new/' . $profile_contact['id'];
} elseif ($visitor_is_authenticated && !empty($profile['unkmail'])) {
$wallmessage_link = 'profile/' . $profile['nickname'] . '/unkmail';
} }
} }
} }

View File

@ -1,165 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2010-2024, 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\Profile;
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database;
use Friendica\Model\Mail;
use Friendica\Model\User;
use Friendica\Module\Response;
use Friendica\Navigation\SystemMessages;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
/**
* Unknown Mail module
*/
class UnkMail extends \Friendica\BaseModule
{
/** @var IHandleUserSessions */
private $userSessions;
/** @var SystemMessages */
private $systemMessages;
/** @var Database */
private $database;
/** @var App\Page */
private $page;
public function __construct(App\Page $page, Database $database, SystemMessages $systemMessages, IHandleUserSessions $userSessions, 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->userSessions = $userSessions;
$this->systemMessages = $systemMessages;
$this->database = $database;
$this->page = $page;
}
protected function post(array $request = [])
{
$replyto = $this->userSessions->getMyUrl();
if (!$replyto) {
$this->systemMessages->addNotice($this->l10n->t('Permission denied.'));
return;
}
$recipient = $this->parameters['nickname'];
$subject = trim($request['subject'] ?? '');
$body = Strings::escapeHtml(trim($request['body'] ?? ''));
if (!$body) {
$this->systemMessages->addNotice($this->l10n->t('Empty message body.'));
return;
}
$user = User::getByNickname($recipient);
if (empty($user)) {
return;
}
if (!$user['unkmail']) {
return;
}
$total = $this->database->count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]);
if ($total > $user['cntunkmail']) {
return;
}
$ret = Mail::sendWall($user, $body, $subject, $replyto);
switch ($ret) {
case -1:
$this->systemMessages->addNotice($this->l10n->t('No recipient selected.'));
break;
case -2:
$this->systemMessages->addNotice($this->l10n->t('Unable to check your home location.'));
break;
case -3:
$this->systemMessages->addNotice($this->l10n->t('Message could not be sent.'));
break;
case -4:
$this->systemMessages->addNotice($this->l10n->t('Message collection failure.'));
break;
}
$this->baseUrl->redirect('profile/' . $user['nickname']);
}
protected function content(array $request = []): string
{
$returnUrl = 'profile/' . $this->parameters['nickname'];
if (!$this->userSessions->getMyUrl()) {
$this->systemMessages->addNotice($this->l10n->t('Permission denied.'));
$this->baseUrl->redirect($returnUrl);
}
$user = User::getByNickname($this->parameters['nickname']);
if (empty($user)) {
$this->systemMessages->addNotice($this->l10n->t('Recipient not found.'));
$this->baseUrl->redirect($returnUrl);
}
if (!$user['unkmail']) {
$this->systemMessages->addNotice($this->l10n->t('Permission denied.'));
$this->baseUrl->redirect($returnUrl);
}
$total = $this->database->count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]);
if ($total > $user['cntunkmail']) {
$this->systemMessages->addNotice($this->l10n->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
$this->baseUrl->redirect($returnUrl);
}
$tpl = Renderer::getMarkupTemplate('profile/unkmail-header.tpl');
$this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$nickname' => $user['nickname'],
'$linkurl' => $this->l10n->t('Please enter a link URL:')
]);
$tpl = Renderer::getMarkupTemplate('profile/unkmail.tpl');
return Renderer::replaceMacros($tpl, [
'$l10n' => [
'header' => $this->l10n->t('Send Private Message'),
'subheader' => $this->l10n->t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.', $user['username']),
'insert' => $this->l10n->t('Insert web link'),
'wait' => $this->l10n->t('Please wait'),
'submit' => $this->l10n->t('Submit'),
],
'$nickname' => $user['nickname'],
'$to' => ['to' , $this->l10n->t('To') , $user['username'], '', '', 'disabled'],
'$subject' => ['subject', $this->l10n->t('Subject') , $request['subject'] ?? ''],
'$body' => ['body' , $this->l10n->t('Your message'), $request['body'] ?? ''],
]);
}
}

View File

@ -160,8 +160,6 @@ class Account extends BaseSettings
$hidewall = !empty($request['hidewall']); $hidewall = !empty($request['hidewall']);
$blockwall = empty($request['blockwall']); // this setting is inverted! $blockwall = empty($request['blockwall']); // this setting is inverted!
$blocktags = empty($request['blocktags']); // this setting is inverted! $blocktags = empty($request['blocktags']); // this setting is inverted!
$unkmail = !empty($request['unkmail']);
$cntunkmail = intval($request['cntunkmail'] ?? 0);
$def_gid = intval($request['circle-selection'] ?? 0); $def_gid = intval($request['circle-selection'] ?? 0);
$aclFormatter = DI::aclFormatter(); $aclFormatter = DI::aclFormatter();
@ -185,8 +183,6 @@ class Account extends BaseSettings
'blockwall' => $blockwall, 'blockwall' => $blockwall,
'hidewall' => $hidewall, 'hidewall' => $hidewall,
'blocktags' => $blocktags, 'blocktags' => $blocktags,
'unkmail' => $unkmail,
'cntunkmail' => $cntunkmail,
]; ];
$profile_fields = [ $profile_fields = [
@ -408,8 +404,6 @@ class Account extends BaseSettings
$openid = $user['openid']; $openid = $user['openid'];
$maxreq = $user['maxreq']; $maxreq = $user['maxreq'];
$expire = $user['expire'] ?: ''; $expire = $user['expire'] ?: '';
$unkmail = $user['unkmail'];
$cntunkmail = $user['cntunkmail'];
$expire_items = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'items', true); $expire_items = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'items', true);
$expire_notes = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'notes', true); $expire_notes = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'notes', true);
@ -571,8 +565,6 @@ class Account extends BaseSettings
'$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")], '$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
'$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')], '$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')],
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')], '$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
'$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid'], 'circle-selection', DI::l10n()->t('Default privacy circle for new contacts')), '$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid'], 'circle-selection', DI::l10n()->t('Default privacy circle for new contacts')),
'$circle_select_group' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'default-group-gid', $user['def_gid']), 'circle-selection-group', DI::l10n()->t('Default privacy circle for new group contacts')), '$circle_select_group' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'default-group-gid', $user['def_gid']), 'circle-selection-group', DI::l10n()->t('Default privacy circle for new group contacts')),
'$permissions' => DI::l10n()->t('Default Post Permissions'), '$permissions' => DI::l10n()->t('Default Post Permissions'),

View File

@ -130,8 +130,6 @@ return [
"blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"], "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"],
"hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unknown viewers"], "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unknown viewers"],
"blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"], "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"],
"unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"],
"cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""],
"notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"], "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"],
"page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"], "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"],
"account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],

View File

@ -1002,8 +1002,6 @@
"blockwall" => ["user", "blockwall"], "blockwall" => ["user", "blockwall"],
"hidewall" => ["user", "hidewall"], "hidewall" => ["user", "hidewall"],
"blocktags" => ["user", "blocktags"], "blocktags" => ["user", "blocktags"],
"unkmail" => ["user", "unkmail"],
"cntunkmail" => ["user", "cntunkmail"],
"notify-flags" => ["user", "notify-flags"], "notify-flags" => ["user", "notify-flags"],
"page-flags" => ["user", "page-flags"], "page-flags" => ["user", "page-flags"],
"account-type" => ["user", "account-type"], "account-type" => ["user", "account-type"],

View File

@ -41,7 +41,6 @@ $profileRoutes = [
'/restricted' => [Module\Profile\Restricted::class, [R::GET ]], '/restricted' => [Module\Profile\Restricted::class, [R::GET ]],
'/schedule' => [Module\Profile\Schedule::class, [R::GET, R::POST]], '/schedule' => [Module\Profile\Schedule::class, [R::GET, R::POST]],
'/conversations[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Conversations::class, [R::GET]], '/conversations[/{category}[/{date1}[/{date2}]]]' => [Module\Profile\Conversations::class, [R::GET]],
'/unkmail' => [Module\Profile\UnkMail::class, [R::GET, R::POST]],
]; ];
$apiRoutes = [ $apiRoutes = [
@ -125,7 +124,7 @@ $apiRoutes = [
'/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Lists::class, [R::GET ]], '/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Lists::class, [R::GET ]],
'/ownerships[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Ownership::class, [R::GET ]], '/ownerships[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Ownership::class, [R::GET ]],
'/statuses[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Statuses::class, [R::GET ]], '/statuses[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Statuses::class, [R::GET ]],
'/subscriptions[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Lists\Lists::class, [R::GET ]], '/subscriptions[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Lists::class, [R::GET ]],
'/update[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Update::class, [ R::POST]], '/update[.{extension:json|xml|rss|atom}]' => [Module\Api\Twitter\Lists\Update::class, [ R::POST]],
], ],

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
<script language="javascript" type="text/javascript">
$("#id_body").editor_autocomplete(baseurl + '/search/acl');
</script>
<script>
function jotGetLink() {
reply = prompt("{{$linkurl}}");
if (reply && reply.length) {
$('#profile-rotator').show();
$.get('parseurl?url=' + reply, function (data) {
addeditortext(data);
$('#profile-rotator').hide();
});
}
}
</script>

View File

@ -1,26 +0,0 @@
<div class="generic-page-wrapper">
<h2>{{$l10n.header}}</h2>
<p>{{$l10n.subheader}}</p>
<div id="prvmail-wrapper">
<form id="prvmail-form" action="profile/{{$nickname}}/unkmail" method="post">
{{include file="field_input.tpl" field=$to}}
{{include file="field_input.tpl" field=$subject}}
{{include file="field_textarea.tpl" field=$body}}
<div id="prvmail-submit-wrapper">
<button type="submit" id="prvmail-submit" class="btn btn-primary" name="submit">
{{$l10n.submit}}
</button>
<div id="prvmail-link-wrapper">
<div id="prvmail-link" class="icon border link" title="{{$l10n.insert}}" onclick="jotGetLink();"></div>
</div>
<div id="prvmail-rotator-wrapper">
<img id="prvmail-rotator" src="images/rotator.gif" alt="{{$l10n.wait}}" title="{{$l10n.wait}}" style="display: none;"/>
</div>
</div>
<div id="prvmail-end"></div>
</form>
</div>
</div>

View File

@ -56,8 +56,6 @@
{{include file="field_checkbox.tpl" field=$blockwall}} {{include file="field_checkbox.tpl" field=$blockwall}}
{{include file="field_checkbox.tpl" field=$blocktags}} {{include file="field_checkbox.tpl" field=$blocktags}}
{{/if}} {{/if}}
{{include file="field_checkbox.tpl" field=$unkmail}}
{{include file="field_input.tpl" field=$cntunkmail}}
{{$circle_select nofilter}} {{$circle_select nofilter}}
{{$circle_select_group nofilter}} {{$circle_select_group nofilter}}

View File

@ -88,8 +88,6 @@
{{include file="field_checkbox.tpl" field=$blockwall}} {{include file="field_checkbox.tpl" field=$blockwall}}
{{include file="field_checkbox.tpl" field=$blocktags}} {{include file="field_checkbox.tpl" field=$blocktags}}
{{/if}} {{/if}}
{{include file="field_checkbox.tpl" field=$unkmail}}
{{include file="field_input.tpl" field=$cntunkmail}}
{{$circle_select nofilter}} {{$circle_select nofilter}}

View File

@ -4494,7 +4494,6 @@ div #datebrowse-sidebar.widget {
} }
#id_maxreq, #id_maxreq,
#id_cntunkmail,
#id_expire { #id_expire {
width: 75px; width: 75px;
} }