mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
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
This commit is contained in:
parent
f6e635c8d2
commit
49e53d5709
1 changed files with 50 additions and 14 deletions
|
@ -203,6 +203,36 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
|||
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 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor {
|
|||
|
||||
$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;
|
||||
|
|
Loading…
Reference in a new issue