2013-01-25 02:23:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
|
|
|
|
2013-05-31 01:37:51 +02:00
|
|
|
const ERROR_EMPTY_PARTICIPANTS = 'error-empty-participants';
|
|
|
|
const ERROR_EMPTY_MESSAGE = 'error-empty-message';
|
|
|
|
|
2014-08-12 21:28:41 +02:00
|
|
|
public function getEditorApplicationClass() {
|
|
|
|
return 'PhabricatorConpherenceApplication';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEditorObjectsDescription() {
|
|
|
|
return pht('Conpherence Threads');
|
|
|
|
}
|
|
|
|
|
2013-05-31 01:37:51 +02:00
|
|
|
public static function createConpherence(
|
|
|
|
PhabricatorUser $creator,
|
|
|
|
array $participant_phids,
|
|
|
|
$title,
|
|
|
|
$message,
|
|
|
|
PhabricatorContentSource $source) {
|
|
|
|
|
|
|
|
$conpherence = id(new ConpherenceThread())
|
|
|
|
->attachParticipants(array())
|
|
|
|
->attachFilePHIDs(array())
|
|
|
|
->setMessageCount(0);
|
|
|
|
$files = array();
|
|
|
|
$errors = array();
|
|
|
|
if (empty($participant_phids)) {
|
|
|
|
$errors[] = self::ERROR_EMPTY_PARTICIPANTS;
|
|
|
|
} else {
|
|
|
|
$participant_phids[] = $creator->getPHID();
|
|
|
|
$participant_phids = array_unique($participant_phids);
|
|
|
|
$conpherence->setRecentParticipantPHIDs(
|
|
|
|
array_slice($participant_phids, 0, 10));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($message)) {
|
|
|
|
$errors[] = self::ERROR_EMPTY_MESSAGE;
|
|
|
|
}
|
|
|
|
|
2014-04-24 01:30:38 +02:00
|
|
|
$file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles(
|
|
|
|
$creator,
|
|
|
|
array($message));
|
2013-05-31 01:37:51 +02:00
|
|
|
if ($file_phids) {
|
|
|
|
$files = id(new PhabricatorFileQuery())
|
|
|
|
->setViewer($creator)
|
|
|
|
->withPHIDs($file_phids)
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$errors) {
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
|
|
->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)
|
|
|
|
->setNewValue(array('+' => $participant_phids));
|
|
|
|
if ($files) {
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
|
|
->setTransactionType(ConpherenceTransactionType::TYPE_FILES)
|
|
|
|
->setNewValue(array('+' => mpull($files, 'getPHID')));
|
|
|
|
}
|
|
|
|
if ($title) {
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
|
|
->setTransactionType(ConpherenceTransactionType::TYPE_TITLE)
|
|
|
|
->setNewValue($title);
|
|
|
|
}
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
|
|
->attachComment(
|
|
|
|
id(new ConpherenceTransactionComment())
|
|
|
|
->setContent($message)
|
|
|
|
->setConpherencePHID($conpherence->getPHID()));
|
|
|
|
|
|
|
|
id(new ConpherenceEditor())
|
|
|
|
->setContentSource($source)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setActor($creator)
|
|
|
|
->applyTransactions($conpherence, $xactions);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return array($errors, $conpherence);
|
|
|
|
}
|
|
|
|
|
2013-01-27 04:56:39 +01:00
|
|
|
public function generateTransactionsFromText(
|
2014-04-24 01:30:38 +02:00
|
|
|
PhabricatorUser $viewer,
|
2013-01-27 04:56:39 +01:00
|
|
|
ConpherenceThread $conpherence,
|
|
|
|
$text) {
|
|
|
|
|
|
|
|
$files = array();
|
2014-04-24 01:30:38 +02:00
|
|
|
$file_phids = PhabricatorMarkupEngine::extractFilePHIDsFromEmbeddedFiles(
|
|
|
|
$viewer,
|
|
|
|
array($text));
|
2013-01-27 04:56:39 +01:00
|
|
|
// Since these are extracted from text, we might be re-including the
|
|
|
|
// same file -- e.g. a mock under discussion. Filter files we
|
|
|
|
// already have.
|
|
|
|
$existing_file_phids = $conpherence->getFilePHIDs();
|
|
|
|
$file_phids = array_diff($file_phids, $existing_file_phids);
|
|
|
|
if ($file_phids) {
|
|
|
|
$files = id(new PhabricatorFileQuery())
|
|
|
|
->setViewer($this->getActor())
|
|
|
|
->withPHIDs($file_phids)
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
$xactions = array();
|
|
|
|
if ($files) {
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
|
|
->setTransactionType(ConpherenceTransactionType::TYPE_FILES)
|
|
|
|
->setNewValue(array('+' => mpull($files, 'getPHID')));
|
|
|
|
}
|
|
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
|
|
|
->attachComment(
|
|
|
|
id(new ConpherenceTransactionComment())
|
|
|
|
->setContent($text)
|
2013-02-19 22:33:10 +01:00
|
|
|
->setConpherencePHID($conpherence->getPHID()));
|
2013-01-27 04:56:39 +01:00
|
|
|
return $xactions;
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
public function getTransactionTypes() {
|
|
|
|
$types = parent::getTransactionTypes();
|
|
|
|
|
|
|
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
|
|
|
|
|
|
|
$types[] = ConpherenceTransactionType::TYPE_TITLE;
|
|
|
|
$types[] = ConpherenceTransactionType::TYPE_PARTICIPANTS;
|
|
|
|
$types[] = ConpherenceTransactionType::TYPE_FILES;
|
|
|
|
|
|
|
|
return $types;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getCustomTransactionOldValue(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
|
|
|
return $object->getTitle();
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
return $object->getParticipantPHIDs();
|
|
|
|
case ConpherenceTransactionType::TYPE_FILES:
|
|
|
|
return $object->getFilePHIDs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getCustomTransactionNewValue(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
|
|
|
return $xaction->getNewValue();
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
case ConpherenceTransactionType::TYPE_FILES:
|
|
|
|
return $this->getPHIDTransactionNewValue($xaction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-05 01:57:38 +02:00
|
|
|
/**
|
|
|
|
* We really only need a read lock if we have a comment. In that case, we
|
|
|
|
* must update the messagesCount field on the conpherence and
|
|
|
|
* seenMessagesCount(s) for the participant(s).
|
|
|
|
*/
|
|
|
|
protected function shouldReadLock(
|
2013-01-25 02:23:05 +01:00
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
2013-04-05 01:57:38 +02:00
|
|
|
$lock = false;
|
2013-01-25 02:23:05 +01:00
|
|
|
switch ($xaction->getTransactionType()) {
|
2013-04-05 01:57:38 +02:00
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
$lock = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $lock;
|
|
|
|
}
|
|
|
|
|
2013-08-15 02:32:16 +02:00
|
|
|
/**
|
|
|
|
* We need to apply initial effects IFF the conpherence is new. We must
|
|
|
|
* save the conpherence first thing to make sure we have an id and a phid.
|
|
|
|
*/
|
|
|
|
protected function shouldApplyInitialEffects(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
return !$object->getID();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyInitialEffects(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
$object->save();
|
|
|
|
}
|
|
|
|
|
2013-04-05 01:57:38 +02:00
|
|
|
protected function applyCustomInternalTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
$object->setMessageCount((int)$object->getMessageCount() + 1);
|
|
|
|
break;
|
2013-01-25 02:23:05 +01:00
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
|
|
|
$object->setTitle($xaction->getNewValue());
|
|
|
|
break;
|
2014-12-04 20:54:17 +01:00
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
|
|
|
// If this is a new ConpherenceThread, we have to create the
|
|
|
|
// participation data asap to pass policy checks. For existing
|
|
|
|
// ConpherenceThreads, the existing participation is correct
|
|
|
|
// at this stage. Note that later in applyCustomExternalTransaction
|
|
|
|
// this participation data will be updated, particularly the
|
|
|
|
// behindTransactionPHID which is just a generated dummy for now.
|
|
|
|
if ($this->getIsNewObject()) {
|
|
|
|
$participants = array();
|
|
|
|
foreach ($xaction->getNewValue() as $phid) {
|
|
|
|
if ($phid == $this->getActor()->getPHID()) {
|
|
|
|
$status = ConpherenceParticipationStatus::UP_TO_DATE;
|
|
|
|
$message_count = 1;
|
|
|
|
} else {
|
|
|
|
$status = ConpherenceParticipationStatus::BEHIND;
|
|
|
|
$message_count = 0;
|
|
|
|
}
|
|
|
|
$participants[$phid] =
|
|
|
|
id(new ConpherenceParticipant())
|
|
|
|
->setConpherencePHID($object->getPHID())
|
|
|
|
->setParticipantPHID($phid)
|
|
|
|
->setParticipationStatus($status)
|
|
|
|
->setDateTouched(time())
|
|
|
|
->setBehindTransactionPHID($xaction->generatePHID())
|
|
|
|
->setSeenMessageCount($message_count)
|
|
|
|
->save();
|
|
|
|
$object->attachParticipants($participants);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
2013-04-05 01:57:38 +02:00
|
|
|
$this->updateRecentParticipantPHIDs($object, $xaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function updateRecentParticipantPHIDs(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
$participants = $object->getRecentParticipantPHIDs();
|
|
|
|
array_unshift($participants, $xaction->getAuthorPHID());
|
|
|
|
$participants = array_slice(array_unique($participants), 0, 10);
|
|
|
|
|
|
|
|
$object->setRecentParticipantPHIDs($participants);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyCustomExternalTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case ConpherenceTransactionType::TYPE_FILES:
|
2014-07-18 00:41:42 +02:00
|
|
|
$editor = new PhabricatorEdgeEditor();
|
2015-01-03 00:33:25 +01:00
|
|
|
$edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST;
|
2013-03-08 19:40:06 +01:00
|
|
|
$old = array_fill_keys($xaction->getOldValue(), true);
|
|
|
|
$new = array_fill_keys($xaction->getNewValue(), true);
|
|
|
|
$add_edges = array_keys(array_diff_key($new, $old));
|
|
|
|
$remove_edges = array_keys(array_diff_key($old, $new));
|
|
|
|
foreach ($add_edges as $file_phid) {
|
2013-01-25 02:23:05 +01:00
|
|
|
$editor->addEdge(
|
|
|
|
$object->getPHID(),
|
|
|
|
$edge_type,
|
2013-02-19 22:33:10 +01:00
|
|
|
$file_phid);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
2013-03-08 19:40:06 +01:00
|
|
|
foreach ($remove_edges as $file_phid) {
|
|
|
|
$editor->removeEdge(
|
|
|
|
$object->getPHID(),
|
|
|
|
$edge_type,
|
|
|
|
$file_phid);
|
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
$editor->save();
|
|
|
|
break;
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
2013-04-02 18:32:40 +02:00
|
|
|
$participants = $object->getParticipants();
|
|
|
|
|
|
|
|
$old_map = array_fuse($xaction->getOldValue());
|
|
|
|
$new_map = array_fuse($xaction->getNewValue());
|
|
|
|
|
|
|
|
$remove = array_keys(array_diff_key($old_map, $new_map));
|
|
|
|
foreach ($remove as $phid) {
|
|
|
|
$remove_participant = $participants[$phid];
|
|
|
|
$remove_participant->delete();
|
|
|
|
unset($participants[$phid]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$add = array_keys(array_diff_key($new_map, $old_map));
|
|
|
|
foreach ($add as $phid) {
|
2014-12-04 20:54:17 +01:00
|
|
|
if ($this->getIsNewObject()) {
|
|
|
|
$participants[$phid]
|
|
|
|
->setBehindTransactionPHID($xaction->getPHID())
|
|
|
|
->save();
|
2013-01-25 02:23:05 +01:00
|
|
|
} else {
|
2014-12-04 20:54:17 +01:00
|
|
|
if ($phid == $this->getActor()->getPHID()) {
|
|
|
|
$status = ConpherenceParticipationStatus::UP_TO_DATE;
|
|
|
|
$message_count = $object->getMessageCount();
|
|
|
|
} else {
|
|
|
|
$status = ConpherenceParticipationStatus::BEHIND;
|
|
|
|
$message_count = 0;
|
|
|
|
}
|
|
|
|
$participants[$phid] =
|
|
|
|
id(new ConpherenceParticipant())
|
|
|
|
->setConpherencePHID($object->getPHID())
|
|
|
|
->setParticipantPHID($phid)
|
|
|
|
->setParticipationStatus($status)
|
|
|
|
->setDateTouched(time())
|
|
|
|
->setBehindTransactionPHID($xaction->getPHID())
|
|
|
|
->setSeenMessageCount($message_count)
|
|
|
|
->save();
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
}
|
2013-03-26 21:30:35 +01:00
|
|
|
$object->attachParticipants($participants);
|
2013-01-25 02:23:05 +01:00
|
|
|
break;
|
2013-04-26 19:30:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyFinalEffects(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
// update everyone's participation status on the last xaction -only-
|
|
|
|
$xaction = end($xactions);
|
|
|
|
$xaction_phid = $xaction->getPHID();
|
|
|
|
$behind = ConpherenceParticipationStatus::BEHIND;
|
|
|
|
$up_to_date = ConpherenceParticipationStatus::UP_TO_DATE;
|
|
|
|
$participants = $object->getParticipants();
|
|
|
|
$user = $this->getActor();
|
|
|
|
$time = time();
|
|
|
|
foreach ($participants as $phid => $participant) {
|
|
|
|
if ($phid != $user->getPHID()) {
|
|
|
|
if ($participant->getParticipationStatus() != $behind) {
|
|
|
|
$participant->setBehindTransactionPHID($xaction_phid);
|
|
|
|
// decrement one as this is the message putting them behind!
|
|
|
|
$participant->setSeenMessageCount($object->getMessageCount() - 1);
|
|
|
|
}
|
|
|
|
$participant->setParticipationStatus($behind);
|
|
|
|
$participant->setDateTouched($time);
|
|
|
|
} else {
|
|
|
|
$participant->setSeenMessageCount($object->getMessageCount());
|
|
|
|
$participant->setParticipationStatus($up_to_date);
|
|
|
|
$participant->setDateTouched($time);
|
|
|
|
}
|
|
|
|
$participant->save();
|
|
|
|
}
|
Update overall revision status after reviewers change
Summary:
Ref T2222. This doesn't feel super clean, but doesn't feel too bad either.
Basically, Differential transactions can have secondary state-based effects (changing the overall revision status) when reviewers resign, are removed, accept, or reject revisions.
To deal with this in ApplicationTransactions, I did this:
- `applyFinalEffects()` can now alter the transaction set (notably, add new ones). This mostly matters for email, notifications and feed.
- In Differential, check for an overall revision state transition in `applyFinalEffects()` (e.g., your reject moving the revision to a rejected state).
- I'm only writing the transaction if the transition is implied and indirect.
- For example, if you "Plan Changes", that action changes the state on its own so there's no implicit state change transaction added.
The transactions themselves are kind of fluff, but it seems useful to keep a record of when state changes occurred in the transaction log. If people complain we can hide/remove them.
Test Plan: {F118143}
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2222
Differential Revision: https://secure.phabricator.com/D8339
2014-02-25 21:36:49 +01:00
|
|
|
|
2014-06-11 22:52:15 +02:00
|
|
|
if ($xactions) {
|
|
|
|
$data = array(
|
|
|
|
'type' => 'message',
|
|
|
|
'threadPHID' => $object->getPHID(),
|
|
|
|
'messageID' => last($xactions)->getID(),
|
|
|
|
'subscribers' => array($object->getPHID()),
|
|
|
|
);
|
|
|
|
|
|
|
|
PhabricatorNotificationClient::tryToPostMessage($data);
|
|
|
|
}
|
|
|
|
|
Update overall revision status after reviewers change
Summary:
Ref T2222. This doesn't feel super clean, but doesn't feel too bad either.
Basically, Differential transactions can have secondary state-based effects (changing the overall revision status) when reviewers resign, are removed, accept, or reject revisions.
To deal with this in ApplicationTransactions, I did this:
- `applyFinalEffects()` can now alter the transaction set (notably, add new ones). This mostly matters for email, notifications and feed.
- In Differential, check for an overall revision state transition in `applyFinalEffects()` (e.g., your reject moving the revision to a rejected state).
- I'm only writing the transaction if the transition is implied and indirect.
- For example, if you "Plan Changes", that action changes the state on its own so there's no implicit state change transaction added.
The transactions themselves are kind of fluff, but it seems useful to keep a record of when state changes occurred in the transaction log. If people complain we can hide/remove them.
Test Plan: {F118143}
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2222
Differential Revision: https://secure.phabricator.com/D8339
2014-02-25 21:36:49 +01:00
|
|
|
return $xactions;
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function mergeTransactions(
|
|
|
|
PhabricatorApplicationTransaction $u,
|
|
|
|
PhabricatorApplicationTransaction $v) {
|
|
|
|
|
|
|
|
$type = $u->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case ConpherenceTransactionType::TYPE_TITLE:
|
|
|
|
return $v;
|
|
|
|
case ConpherenceTransactionType::TYPE_FILES:
|
|
|
|
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
|
2013-03-28 16:34:34 +01:00
|
|
|
return $this->mergePHIDOrEdgeTransactions($u, $v);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::mergeTransactions($u, $v);
|
|
|
|
}
|
|
|
|
|
2013-09-14 00:08:17 +02:00
|
|
|
protected function shouldSendMail(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
2013-01-26 01:03:54 +01:00
|
|
|
return true;
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
|
|
|
|
return id(new ConpherenceReplyHandler())
|
2013-01-26 01:03:54 +01:00
|
|
|
->setActor($this->getActor())
|
2013-01-25 02:23:05 +01:00
|
|
|
->setMailReceiver($object);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
|
|
|
|
$id = $object->getID();
|
|
|
|
$title = $object->getTitle();
|
2013-01-26 01:03:54 +01:00
|
|
|
if (!$title) {
|
|
|
|
$title = pht(
|
|
|
|
'%s sent you a message.',
|
2013-02-19 22:33:10 +01:00
|
|
|
$this->getActor()->getUserName());
|
2013-01-26 01:03:54 +01:00
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
$phid = $object->getPHID();
|
|
|
|
|
|
|
|
return id(new PhabricatorMetaMTAMail())
|
2013-01-26 01:03:54 +01:00
|
|
|
->setSubject("E{$id}: {$title}")
|
|
|
|
->addHeader('Thread-Topic', "E{$id}: {$phid}");
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getMailTo(PhabricatorLiskDAO $object) {
|
2013-04-02 18:32:40 +02:00
|
|
|
$to_phids = array();
|
2013-01-25 02:23:05 +01:00
|
|
|
$participants = $object->getParticipants();
|
2013-04-02 18:32:40 +02:00
|
|
|
if (empty($participants)) {
|
|
|
|
return $to_phids;
|
|
|
|
}
|
2013-03-26 21:30:35 +01:00
|
|
|
$preferences = id(new PhabricatorUserPreferences())
|
|
|
|
->loadAllWhere('userPHID in (%Ls)', array_keys($participants));
|
|
|
|
$preferences = mpull($preferences, null, 'getUserPHID');
|
|
|
|
foreach ($participants as $phid => $participant) {
|
|
|
|
$default = ConpherenceSettings::EMAIL_ALWAYS;
|
|
|
|
$preference = idx($preferences, $phid);
|
|
|
|
if ($preference) {
|
|
|
|
$default = $preference->getPreference(
|
|
|
|
PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS,
|
|
|
|
ConpherenceSettings::EMAIL_ALWAYS);
|
|
|
|
}
|
|
|
|
$settings = $participant->getSettings();
|
|
|
|
$notifications = idx(
|
|
|
|
$settings,
|
|
|
|
'notifications',
|
|
|
|
$default);
|
|
|
|
if ($notifications == ConpherenceSettings::EMAIL_ALWAYS) {
|
|
|
|
$to_phids[] = $phid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $to_phids;
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
|
2013-01-26 01:03:54 +01:00
|
|
|
protected function getMailCC(PhabricatorLiskDAO $object) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
protected function buildMailBody(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
$body = parent::buildMailBody($object, $xactions);
|
2014-10-30 23:24:10 +01:00
|
|
|
$body->addLinkSection(
|
2013-01-25 02:23:05 +01:00
|
|
|
pht('CONPHERENCE DETAIL'),
|
|
|
|
PhabricatorEnv::getProductionURI('/conpherence/'.$object->getID().'/'));
|
|
|
|
|
|
|
|
return $body;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getMailSubjectPrefix() {
|
|
|
|
return PhabricatorEnv::getEnvConfig('metamta.conpherence.subject-prefix');
|
|
|
|
}
|
|
|
|
|
2014-03-05 02:01:33 +01:00
|
|
|
protected function shouldPublishFeedStory(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
2013-01-25 02:23:05 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function supportsSearch() {
|
2015-01-06 19:24:30 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getSearchContextParameter(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
array $xactions) {
|
|
|
|
|
|
|
|
$comment_phids = array();
|
|
|
|
foreach ($xactions as $xaction) {
|
|
|
|
if ($xaction->hasComment()) {
|
|
|
|
$comment_phids[] = $xaction->getPHID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'commentPHIDs' => $comment_phids,
|
|
|
|
);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
2014-07-10 00:12:48 +02:00
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|