Merge pull request #1313 from MrPetovan/bug/7574-notifications-deleted-users

[various] Use new centralized admin account retrieval methods
This commit is contained in:
Tobias Diekershoff 2022-11-18 18:05:37 +01:00 committed by GitHub
commit 174fae82ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View file

@ -40,15 +40,17 @@ function notifyall_post(App $a)
return; return;
} }
$condition = ['account_removed' => false, 'account_expired' => false];
// if this is a test, send it only to the admin(s) // if this is a test, send it only to the admin(s)
// admin_email might be a comma separated list, but we need "a@b','c@d','e@f // admin_email might be a comma separated list, but we need "a@b','c@d','e@f
if (intval($_REQUEST['test'])) { if (intval($_REQUEST['test'])) {
$email = DI::config()->get('config', 'admin_email'); $adminEmails = \Friendica\Model\User::getAdminListForEmailing(['email']);
$email = "'" . str_replace([" ",","], ["","','"], $email) . "'";
}
$sql_extra = ((intval($_REQUEST['test'])) ? sprintf(" AND `email` in ( %s )", $email) : '');
$recipients = DBA::p("SELECT DISTINCT `email` FROM `user` WHERE `verified` AND NOT `account_removed` AND NOT `account_expired` $sql_extra"); $condition['email'] = array_column($adminEmails, 'email');
}
$recipients = DBA::p("SELECT DISTINCT `email` FROM `user`" . DBA::buildCondition($condition));
if (! $recipients) { if (! $recipients) {
DI::sysmsg()->addNotice(DI::l10n()->t('No recipients found.')); DI::sysmsg()->addNotice(DI::l10n()->t('No recipients found.'));

View file

@ -99,10 +99,10 @@ function pumpio_registerclient(App $a, $host)
$application_name = DI::baseUrl()->getHostname(); $application_name = DI::baseUrl()->getHostname();
} }
$adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email'))); $firstAdmin = User::getFirstAdmin(['email']);
$params['type'] = 'client_associate'; $params['type'] = 'client_associate';
$params['contacts'] = $adminlist[0]; $params['contacts'] = $firstAdmin['email'];
$params['application_type'] = 'native'; $params['application_type'] = 'native';
$params['application_name'] = $application_name; $params['application_name'] = $application_name;
$params['logo_url'] = DI::baseUrl()->get() . '/images/friendica-256.png'; $params['logo_url'] = DI::baseUrl()->get() . '/images/friendica-256.png';