@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't allow welcome mail to be sent to users who can't login

Summary:
Fixes T9446. We allow administrators to send "Welcome" mail to bots and mailing lists.

This is harmless (these links do not function), but confusing.

Instead, disable this option in the UI and explain why it is disabled when it is clicked. Also prevent generation of this mail lower in the stack.

Test Plan:
- Viewed a bot page, saw action disabled, clicked it, got explanation.
- Viewed a normal user page, saw action enabled, clicked it, sent welcome email.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9446

Differential Revision: https://secure.phabricator.com/D14134

+25 -10
+3
src/applications/people/controller/PhabricatorPeopleProfileController.php
··· 136 136 ->setWorkflow(true) 137 137 ->setHref($this->getApplicationURI('delete/'.$user->getID().'/'))); 138 138 139 + $can_welcome = $user->canEstablishWebSessions(); 140 + 139 141 $actions->addAction( 140 142 id(new PhabricatorActionView()) 141 143 ->setIcon('fa-envelope') 142 144 ->setName(pht('Send Welcome Email')) 143 145 ->setWorkflow(true) 146 + ->setDisabled(!$can_welcome) 144 147 ->setHref($this->getApplicationURI('welcome/'.$user->getID().'/'))); 145 148 } 146 149
+15 -10
src/applications/people/controller/PhabricatorPeopleWelcomeController.php
··· 3 3 final class PhabricatorPeopleWelcomeController 4 4 extends PhabricatorPeopleController { 5 5 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $admin = $request->getUser(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $admin = $this->getViewer(); 15 8 16 9 $user = id(new PhabricatorPeopleQuery()) 17 10 ->setViewer($admin) 18 - ->withIDs(array($this->id)) 11 + ->withIDs(array($request->getURIData('id'))) 19 12 ->executeOne(); 20 13 if (!$user) { 21 14 return new Aphront404Response(); 22 15 } 23 16 24 17 $profile_uri = '/p/'.$user->getUsername().'/'; 18 + 19 + if (!$user->canEstablishWebSessions()) { 20 + return $this->newDialog() 21 + ->setTitle(pht('Not a Normal User')) 22 + ->appendParagraph( 23 + pht( 24 + 'You can not send this user a welcome mail because they are not '. 25 + 'a normal user and can not log in to the web interface. Special '. 26 + 'users (like bots and mailing lists) are unable to establish web '. 27 + 'sessions.')) 28 + ->addCancelButton($profile_uri, pht('Done')); 29 + } 25 30 26 31 if ($request->isFormPost()) { 27 32 $user->sendWelcomeEmail($admin);
+7
src/applications/people/storage/PhabricatorUser.php
··· 587 587 } 588 588 589 589 public function sendWelcomeEmail(PhabricatorUser $admin) { 590 + if (!$this->canEstablishWebSessions()) { 591 + throw new Exception( 592 + pht( 593 + 'Can not send welcome mail to users who can not establish '. 594 + 'web sessions!')); 595 + } 596 + 590 597 $admin_username = $admin->getUserName(); 591 598 $admin_realname = $admin->getRealName(); 592 599 $user_username = $this->getUserName();