From fada3586074cc242fa8e9a9617d7cb9298f84efa Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 18 Nov 2022 12:00:03 -0500 Subject: [PATCH] [various] Use new centralized admin account retrieval methods --- notifyall/notifyall.php | 12 +++++++----- pumpio/pumpio.php | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/notifyall/notifyall.php b/notifyall/notifyall.php index 270557c4..ee05407b 100644 --- a/notifyall/notifyall.php +++ b/notifyall/notifyall.php @@ -40,15 +40,17 @@ function notifyall_post(App $a) return; } + $condition = ['account_removed' => false, 'account_expired' => false]; + // 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 if (intval($_REQUEST['test'])) { - $email = DI::config()->get('config', 'admin_email'); - $email = "'" . str_replace([" ",","], ["","','"], $email) . "'"; - } - $sql_extra = ((intval($_REQUEST['test'])) ? sprintf(" AND `email` in ( %s )", $email) : ''); + $adminEmails = \Friendica\Model\User::getAdminListForEmailing(['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) { DI::sysmsg()->addNotice(DI::l10n()->t('No recipients found.')); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 903450c2..4928b5e4 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -99,10 +99,10 @@ function pumpio_registerclient(App $a, $host) $application_name = DI::baseUrl()->getHostname(); } - $adminlist = explode(',', str_replace(' ', '', DI::config()->get('config', 'admin_email'))); + $firstAdmin = User::getFirstAdmin(['email']); $params['type'] = 'client_associate'; - $params['contacts'] = $adminlist[0]; + $params['contacts'] = $firstAdmin['email']; $params['application_type'] = 'native'; $params['application_name'] = $application_name; $params['logo_url'] = DI::baseUrl()->get() . '/images/friendica-256.png';