1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00
phorge-phorge/src/applications/auth/storage/PhabricatorAuthSSHKeyTransaction.php
epriestley 6f6ca0102d Send forced mail on SSH key edits
Summary:
Ref T10917. This cheats fairly heavily to generate SSH key mail:

  - Generate normal transaction mail.
  - Force it to go to the user.
  - Use `setForceDelivery()` to force it to actually be delivered.
  - Add some warning language to the mail body.

This doesn't move us much closer to Glorious Infrastructure for this whole class of events, but should do what it needs to for now and doesn't really require anything sketchy.

Test Plan: Created and edited SSH keys, got security notice mail.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10917

Differential Revision: https://secure.phabricator.com/D15948
2016-05-19 15:01:25 -07:00

59 lines
1.5 KiB
PHP

<?php
final class PhabricatorAuthSSHKeyTransaction
extends PhabricatorApplicationTransaction {
const TYPE_NAME = 'sshkey.name';
const TYPE_KEY = 'sshkey.key';
const TYPE_DEACTIVATE = 'sshkey.deactivate';
public function getApplicationName() {
return 'auth';
}
public function getApplicationTransactionType() {
return PhabricatorAuthSSHKeyPHIDType::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return null;
}
public function getTitle() {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this key.',
$this->renderHandleLink($author_phid));
case self::TYPE_NAME:
return pht(
'%s renamed this key from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$old,
$new);
case self::TYPE_KEY:
return pht(
'%s updated the public key material for this SSH key.',
$this->renderHandleLink($author_phid));
case self::TYPE_DEACTIVATE:
if ($new) {
return pht(
'%s deactivated this key.',
$this->renderHandleLink($author_phid));
} else {
return pht(
'%s activated this key.',
$this->renderHandleLink($author_phid));
}
}
return parent::getTitle();
}
}