Page MenuHomePhabricator

D10927.id26247.diff
No OneTemporary

D10927.id26247.diff

diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php
--- a/src/applications/conpherence/editor/ConpherenceEditor.php
+++ b/src/applications/conpherence/editor/ConpherenceEditor.php
@@ -203,6 +203,36 @@
case ConpherenceTransactionType::TYPE_TITLE:
$object->setTitle($xaction->getNewValue());
break;
+ 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;
}
$this->updateRecentParticipantPHIDs($object, $xaction);
}
@@ -259,22 +289,28 @@
$add = array_keys(array_diff_key($new_map, $old_map));
foreach ($add as $phid) {
- if ($phid == $this->getActor()->getPHID()) {
- $status = ConpherenceParticipationStatus::UP_TO_DATE;
- $message_count = $object->getMessageCount();
+ if ($this->getIsNewObject()) {
+ $participants[$phid]
+ ->setBehindTransactionPHID($xaction->getPHID())
+ ->save();
} else {
- $status = ConpherenceParticipationStatus::BEHIND;
- $message_count = 0;
+ 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();
}
- $participants[$phid] =
- id(new ConpherenceParticipant())
- ->setConpherencePHID($object->getPHID())
- ->setParticipantPHID($phid)
- ->setParticipationStatus($status)
- ->setDateTouched(time())
- ->setBehindTransactionPHID($xaction->getPHID())
- ->setSeenMessageCount($message_count)
- ->save();
}
$object->attachParticipants($participants);
break;

File Metadata

Mime Type
text/plain
Expires
Sat, May 18, 7:21 AM (2 w, 7 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6293979
Default Alt Text
D10927.id26247.diff (3 KB)

Event Timeline