mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Make revision CCs work properly.
This commit is contained in:
parent
905870d793
commit
38e53df53c
3 changed files with 66 additions and 55 deletions
|
@ -315,6 +315,35 @@ class DifferentialRevisionEditor {
|
|||
array_keys($add['rev']),
|
||||
$this->actorPHID);
|
||||
|
||||
/*
|
||||
|
||||
// TODO: When Herald is brought over, run through this stuff to figure
|
||||
// out which adds are Herald's fault.
|
||||
|
||||
if ($add['ccs'] || $rem['ccs']) {
|
||||
foreach (array_keys($add['ccs']) as $id) {
|
||||
if (empty($new['ccs'][$id])) {
|
||||
$reason_phid = 'TODO';//$xscript_phid;
|
||||
} else {
|
||||
$reason_phid = $this->getActorPHID();
|
||||
}
|
||||
}
|
||||
foreach (array_keys($rem['ccs']) as $id) {
|
||||
if (empty($new['ccs'][$id])) {
|
||||
$reason_phid = $this->getActorPHID();
|
||||
} else {
|
||||
$reason_phid = 'TODO';//$xscript_phid;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
self::alterCCs(
|
||||
$revision,
|
||||
$this->cc,
|
||||
array_keys($rem['ccs']),
|
||||
array_keys($add['ccs']),
|
||||
$this->actorPHID);
|
||||
|
||||
// Add the author to the relevant set of users so they get a copy of the
|
||||
// email.
|
||||
if (!$this->silentUpdate) {
|
||||
|
@ -390,28 +419,7 @@ class DifferentialRevisionEditor {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// $revision->attachReviewers(array_keys($new['rev']));
|
||||
// $revision->attachCCPHIDs(array_keys($new['ccs']));
|
||||
|
||||
if ($add['ccs'] || $rem['ccs']) {
|
||||
foreach (array_keys($add['ccs']) as $id) {
|
||||
if (empty($new['ccs'][$id])) {
|
||||
$reason_phid = 'TODO';//$xscript_phid;
|
||||
} else {
|
||||
$reason_phid = $this->getActorPHID();
|
||||
}
|
||||
self::addCCPHID($revision, $id, $reason_phid);
|
||||
}
|
||||
foreach (array_keys($rem['ccs']) as $id) {
|
||||
if (empty($new['ccs'][$id])) {
|
||||
$reason_phid = $this->getActorPHID();
|
||||
} else {
|
||||
$reason_phid = 'TODO';//$xscript_phid;
|
||||
}
|
||||
self::removeCCPHID($revision, $id, $reason_phid);
|
||||
}
|
||||
}
|
||||
$revision->loadRelationships();
|
||||
|
||||
if ($add['rev']) {
|
||||
$message = id(new DifferentialNewDiffMail(
|
||||
|
@ -458,34 +466,20 @@ class DifferentialRevisionEditor {
|
|||
}
|
||||
}
|
||||
|
||||
public function addCCPHID(
|
||||
protected static function alterCCs(
|
||||
DifferentialRevision $revision,
|
||||
$phid,
|
||||
array $stable_phids,
|
||||
array $rem_phids,
|
||||
array $add_phids,
|
||||
$reason_phid) {
|
||||
self::alterCCPHID($revision, $phid, true, $reason_phid);
|
||||
}
|
||||
|
||||
public function removeCCPHID(
|
||||
DifferentialRevision $revision,
|
||||
$phid,
|
||||
$reason_phid) {
|
||||
self::alterCCPHID($revision, $phid, false, $reason_phid);
|
||||
}
|
||||
|
||||
protected static function alterCCPHID(
|
||||
DifferentialRevision $revision,
|
||||
$phid,
|
||||
$add,
|
||||
$reason_phid) {
|
||||
/*
|
||||
$relationship = new DifferentialRelationship();
|
||||
$relationship->setRevisionID($revision->getID());
|
||||
$relationship->setRelation(DifferentialRelationship::RELATION_SUBSCRIBED);
|
||||
$relationship->setRelatedPHID($phid);
|
||||
$relationship->setForbidden(!$add);
|
||||
$relationship->setReasonPHID($reason_phid);
|
||||
$relationship->replace();
|
||||
*/
|
||||
return self::alterRelationships(
|
||||
$revision,
|
||||
$stable_phids,
|
||||
$rem_phids,
|
||||
$add_phids,
|
||||
$reason_phid,
|
||||
DifferentialRevision::RELATION_SUBSCRIBED);
|
||||
}
|
||||
|
||||
|
||||
|
@ -496,6 +490,23 @@ class DifferentialRevisionEditor {
|
|||
array $add_phids,
|
||||
$reason_phid) {
|
||||
|
||||
return self::alterRelationships(
|
||||
$revision,
|
||||
$stable_phids,
|
||||
$rem_phids,
|
||||
$add_phids,
|
||||
$reason_phid,
|
||||
DifferentialRevision::RELATION_REVIEWER);
|
||||
}
|
||||
|
||||
private static function alterRelationships(
|
||||
DifferentialRevision $revision,
|
||||
array $stable_phids,
|
||||
array $rem_phids,
|
||||
array $add_phids,
|
||||
$reason_phid,
|
||||
$relation_type) {
|
||||
|
||||
$rem_map = array_fill_keys($rem_phids, true);
|
||||
$add_map = array_fill_keys($add_phids, true);
|
||||
|
||||
|
@ -512,11 +523,11 @@ class DifferentialRevisionEditor {
|
|||
}
|
||||
}
|
||||
|
||||
$raw = $revision->getRawRelations(DifferentialRevision::RELATION_REVIEWER);
|
||||
$raw = $revision->getRawRelations($relation_type);
|
||||
$raw = ipull($raw, null, 'objectPHID');
|
||||
|
||||
$sequence = count($seq_map);
|
||||
foreach ($raw as $phid => $relation) {
|
||||
foreach ($raw as $phid => $ignored) {
|
||||
if (isset($seq_map[$phid])) {
|
||||
$raw[$phid]['sequence'] = $seq_map[$phid];
|
||||
} else {
|
||||
|
@ -525,7 +536,7 @@ class DifferentialRevisionEditor {
|
|||
}
|
||||
$raw = isort($raw, 'sequence');
|
||||
|
||||
foreach ($raw as $phid => $relation) {
|
||||
foreach ($raw as $phid => $ignored) {
|
||||
if (isset($rem_map[$phid])) {
|
||||
unset($raw[$phid]);
|
||||
}
|
||||
|
@ -547,7 +558,7 @@ class DifferentialRevisionEditor {
|
|||
$conn_w,
|
||||
'(%d, %s, %s, %d, %s)',
|
||||
$revision->getID(),
|
||||
DifferentialRevision::RELATION_REVIEWER,
|
||||
$relation_type,
|
||||
$relation['objectPHID'],
|
||||
$relation['sequence'],
|
||||
$relation['reasonPHID']);
|
||||
|
@ -559,7 +570,7 @@ class DifferentialRevisionEditor {
|
|||
'DELETE FROM %T WHERE revisionID = %d AND relation = %s',
|
||||
DifferentialRevision::RELATIONSHIP_TABLE,
|
||||
$revision->getID(),
|
||||
DifferentialRevision::RELATION_REVIEWER);
|
||||
$relation_type);
|
||||
if ($sql) {
|
||||
queryfx(
|
||||
$conn_w,
|
||||
|
|
|
@ -20,13 +20,13 @@ class DifferentialCCWelcomeMail extends DifferentialReviewRequestMail {
|
|||
|
||||
protected function renderSubject() {
|
||||
$revision = $this->getRevision();
|
||||
return 'Added to CC: '.$revision->getName();
|
||||
return 'Added to CC: '.$revision->getTitle();
|
||||
}
|
||||
|
||||
protected function renderBody() {
|
||||
|
||||
$actor = $this->getActorName();
|
||||
$name = $this->getRevision()->getName();
|
||||
$name = $this->getRevision()->getTitle();
|
||||
$body = array();
|
||||
|
||||
$body[] = "{$actor} added you to the CC list for the revision \"{$name}\".";
|
||||
|
|
|
@ -26,7 +26,7 @@ class DifferentialDiffContentMail extends DifferentialMail {
|
|||
}
|
||||
|
||||
protected function renderSubject() {
|
||||
return "Content: ".$this->getRevision()->getName();
|
||||
return "Content: ".$this->getRevision()->getTitle();
|
||||
}
|
||||
|
||||
protected function renderBody() {
|
||||
|
|
Loading…
Reference in a new issue