1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Correctly implementing mailkey for Phurl

Summary: Re T6049, Correctly implementing mailkey for Phurl

Test Plan: Edit Phurl URL, receive email.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14605
This commit is contained in:
lkassianik 2015-11-30 06:44:03 -08:00
parent 9d59086d01
commit 47a5ebb4fe
5 changed files with 34 additions and 7 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_phurl.phurl_url
ADD mailKey binary(20) NOT NULL;

View file

@ -0,0 +1,18 @@
<?php
$table = new PhabricatorPhurlURL();
$conn_w = $table->establishConnection('w');
$iterator = new LiskMigrationIterator($table);
foreach ($iterator as $url) {
$id = $url->getID();
echo pht('Adding mail key for Phurl %d...', $id);
echo "\n";
queryfx(
$conn_w,
'UPDATE %T SET mailKey = %s WHERE id = %d',
$table->getTableName(),
Filesystem::readRandomCharacters(20),
$id);
}

View file

@ -211,11 +211,9 @@ final class PhabricatorPhurlURLEditor
public function getMailTagsMap() {
return array(
PhabricatorPhurlURLTransaction::MAILTAG_CONTENT =>
PhabricatorPhurlURLTransaction::MAILTAG_DETAILS =>
pht(
"A URL's name or path changes."),
PhabricatorPhurlURLTransaction::MAILTAG_OTHER =>
pht('Other event activity not listed above occurs.'),
"A URL's details change."),
);
}

View file

@ -22,6 +22,8 @@ final class PhabricatorPhurlURL extends PhabricatorPhurlDAO
protected $authorPHID;
protected $spacePHID;
protected $mailKey;
const DEFAULT_ICON = 'fa-compress';
public static function initializeNewPhurlURL(PhabricatorUser $actor) {
@ -45,6 +47,7 @@ final class PhabricatorPhurlURL extends PhabricatorPhurlDAO
'alias' => 'sort64?',
'longURL' => 'text',
'description' => 'text',
'mailKey' => 'bytes20',
),
self::CONFIG_KEY_SCHEMA => array(
'key_instance' => array(
@ -58,6 +61,13 @@ final class PhabricatorPhurlURL extends PhabricatorPhurlDAO
) + parent::getConfiguration();
}
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
}
return parent::save();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorPhurlURLPHIDType::TYPECONST);

View file

@ -8,8 +8,7 @@ final class PhabricatorPhurlURLTransaction
const TYPE_ALIAS = 'phurl.alias';
const TYPE_DESCRIPTION = 'phurl.description';
const MAILTAG_CONTENT = 'phurl:content';
const MAILTAG_OTHER = 'phurl:other';
const MAILTAG_DETAILS = 'phurl-details';
public function getApplicationName() {
return 'phurl';
@ -235,7 +234,7 @@ final class PhabricatorPhurlURLTransaction
case self::TYPE_DESCRIPTION:
case self::TYPE_URL:
case self::TYPE_ALIAS:
$tags[] = self::MAILTAG_CONTENT;
$tags[] = self::MAILTAG_DETAILS;
break;
}
return $tags;