diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 45d31361d0..bee0bb7c38 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3216,6 +3216,7 @@ phutil_register_library_map(array( 'PhabricatorEmailFormatSetting' => 'applications/settings/setting/PhabricatorEmailFormatSetting.php', 'PhabricatorEmailFormatSettingsPanel' => 'applications/settings/panel/PhabricatorEmailFormatSettingsPanel.php', 'PhabricatorEmailLoginController' => 'applications/auth/controller/PhabricatorEmailLoginController.php', + 'PhabricatorEmailLoginUserLogType' => 'applications/people/userlog/PhabricatorEmailLoginUserLogType.php', 'PhabricatorEmailNotificationsSetting' => 'applications/settings/setting/PhabricatorEmailNotificationsSetting.php', 'PhabricatorEmailPreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php', 'PhabricatorEmailRePrefixSetting' => 'applications/settings/setting/PhabricatorEmailRePrefixSetting.php', @@ -9343,6 +9344,7 @@ phutil_register_library_map(array( 'PhabricatorEmailFormatSetting' => 'PhabricatorSelectSetting', 'PhabricatorEmailFormatSettingsPanel' => 'PhabricatorEditEngineSettingsPanel', 'PhabricatorEmailLoginController' => 'PhabricatorAuthController', + 'PhabricatorEmailLoginUserLogType' => 'PhabricatorUserLogType', 'PhabricatorEmailNotificationsSetting' => 'PhabricatorSelectSetting', 'PhabricatorEmailPreferencesSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorEmailRePrefixSetting' => 'PhabricatorSelectSetting', diff --git a/src/applications/auth/controller/PhabricatorEmailLoginController.php b/src/applications/auth/controller/PhabricatorEmailLoginController.php index 492526edf5..a744a90a6c 100644 --- a/src/applications/auth/controller/PhabricatorEmailLoginController.php +++ b/src/applications/auth/controller/PhabricatorEmailLoginController.php @@ -104,10 +104,16 @@ final class PhabricatorEmailLoginController if (!$errors) { $target_address = new PhutilEmailAddress($target_email->getAddress()); + $user_log = PhabricatorUserLog::initializeNewLog( + $viewer, + $target_user->getPHID(), + PhabricatorEmailLoginUserLogType::LOGTYPE); + $mail_engine = id(new PhabricatorPeopleEmailLoginMailEngine()) ->setSender($viewer) ->setRecipient($target_user) - ->setRecipientAddress($target_address); + ->setRecipientAddress($target_address) + ->setActivityLog($user_log); try { $mail_engine->validateMail(); diff --git a/src/applications/people/mail/PhabricatorPeopleMailEngine.php b/src/applications/people/mail/PhabricatorPeopleMailEngine.php index c1379dda9e..6b7aa7818e 100644 --- a/src/applications/people/mail/PhabricatorPeopleMailEngine.php +++ b/src/applications/people/mail/PhabricatorPeopleMailEngine.php @@ -6,6 +6,7 @@ abstract class PhabricatorPeopleMailEngine private $sender; private $recipient; private $recipientAddress; + private $activityLog; final public function setSender(PhabricatorUser $sender) { $this->sender = $sender; @@ -47,6 +48,15 @@ abstract class PhabricatorPeopleMailEngine return ($this->recipientAddress !== null); } + final public function setActivityLog(PhabricatorUserLog $activity_log) { + $this->activityLog = $activity_log; + return $this; + } + + final public function getActivityLog() { + return $this->activityLog; + } + final public function canSendMail() { try { $this->validateMail(); @@ -68,6 +78,18 @@ abstract class PhabricatorPeopleMailEngine $mail->addTos(array($recipient->getPHID())); } + $activity_log = $this->getActivityLog(); + if ($activity_log) { + $activity_log->save(); + + $body = array(); + $body[] = rtrim($mail->getBody(), "\n"); + $body[] = pht('Activity Log ID: #%d', $activity_log->getID()); + $body = implode("\n\n", $body)."\n"; + + $mail->setBody($body); + } + $mail ->setForceDelivery(true) ->save(); diff --git a/src/applications/people/userlog/PhabricatorEmailLoginUserLogType.php b/src/applications/people/userlog/PhabricatorEmailLoginUserLogType.php new file mode 100644 index 0000000000..1e49788990 --- /dev/null +++ b/src/applications/people/userlog/PhabricatorEmailLoginUserLogType.php @@ -0,0 +1,12 @@ +