Skip to content

Commit 49e53d5

Browse files
committed
Conpherence - fix permissions issue creating new Conpherences
Summary: Fixes T6690. The editor innards end up loading the conpherence object, whose policy is dictated by these participation objects. Test Plan: pre patch could not create new conpherences. post patch I can create conpherences! i can also add people to conpherences and it works. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6690 Differential Revision: https://secure.phabricator.com/D10927
1 parent f6e635c commit 49e53d5

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

src/applications/conpherence/editor/ConpherenceEditor.php

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,36 @@ protected function applyCustomInternalTransaction(
203203
case ConpherenceTransactionType::TYPE_TITLE:
204204
$object->setTitle($xaction->getNewValue());
205205
break;
206+
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
207+
// If this is a new ConpherenceThread, we have to create the
208+
// participation data asap to pass policy checks. For existing
209+
// ConpherenceThreads, the existing participation is correct
210+
// at this stage. Note that later in applyCustomExternalTransaction
211+
// this participation data will be updated, particularly the
212+
// behindTransactionPHID which is just a generated dummy for now.
213+
if ($this->getIsNewObject()) {
214+
$participants = array();
215+
foreach ($xaction->getNewValue() as $phid) {
216+
if ($phid == $this->getActor()->getPHID()) {
217+
$status = ConpherenceParticipationStatus::UP_TO_DATE;
218+
$message_count = 1;
219+
} else {
220+
$status = ConpherenceParticipationStatus::BEHIND;
221+
$message_count = 0;
222+
}
223+
$participants[$phid] =
224+
id(new ConpherenceParticipant())
225+
->setConpherencePHID($object->getPHID())
226+
->setParticipantPHID($phid)
227+
->setParticipationStatus($status)
228+
->setDateTouched(time())
229+
->setBehindTransactionPHID($xaction->generatePHID())
230+
->setSeenMessageCount($message_count)
231+
->save();
232+
$object->attachParticipants($participants);
233+
}
234+
}
235+
break;
206236
}
207237
$this->updateRecentParticipantPHIDs($object, $xaction);
208238
}
@@ -259,22 +289,28 @@ protected function applyCustomExternalTransaction(
259289

260290
$add = array_keys(array_diff_key($new_map, $old_map));
261291
foreach ($add as $phid) {
262-
if ($phid == $this->getActor()->getPHID()) {
263-
$status = ConpherenceParticipationStatus::UP_TO_DATE;
264-
$message_count = $object->getMessageCount();
292+
if ($this->getIsNewObject()) {
293+
$participants[$phid]
294+
->setBehindTransactionPHID($xaction->getPHID())
295+
->save();
265296
} else {
266-
$status = ConpherenceParticipationStatus::BEHIND;
267-
$message_count = 0;
297+
if ($phid == $this->getActor()->getPHID()) {
298+
$status = ConpherenceParticipationStatus::UP_TO_DATE;
299+
$message_count = $object->getMessageCount();
300+
} else {
301+
$status = ConpherenceParticipationStatus::BEHIND;
302+
$message_count = 0;
303+
}
304+
$participants[$phid] =
305+
id(new ConpherenceParticipant())
306+
->setConpherencePHID($object->getPHID())
307+
->setParticipantPHID($phid)
308+
->setParticipationStatus($status)
309+
->setDateTouched(time())
310+
->setBehindTransactionPHID($xaction->getPHID())
311+
->setSeenMessageCount($message_count)
312+
->save();
268313
}
269-
$participants[$phid] =
270-
id(new ConpherenceParticipant())
271-
->setConpherencePHID($object->getPHID())
272-
->setParticipantPHID($phid)
273-
->setParticipationStatus($status)
274-
->setDateTouched(time())
275-
->setBehindTransactionPHID($xaction->getPHID())
276-
->setSeenMessageCount($message_count)
277-
->save();
278314
}
279315
$object->attachParticipants($participants);
280316
break;

0 commit comments

Comments
 (0)