mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
d6b882a804
Summary: Ref T6822. Test Plan: `grep` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: hach-que, Korvin, epriestley Maniphest Tasks: T6822 Differential Revision: https://secure.phabricator.com/D11370
62 lines
1.8 KiB
PHP
62 lines
1.8 KiB
PHP
<?php
|
|
|
|
final class ConpherenceParticipant extends ConpherenceDAO {
|
|
|
|
protected $participantPHID;
|
|
protected $conpherencePHID;
|
|
protected $participationStatus;
|
|
protected $behindTransactionPHID;
|
|
protected $seenMessageCount;
|
|
protected $dateTouched;
|
|
protected $settings = array();
|
|
|
|
protected function getConfiguration() {
|
|
return array(
|
|
self::CONFIG_SERIALIZATION => array(
|
|
'settings' => self::SERIALIZATION_JSON,
|
|
),
|
|
self::CONFIG_COLUMN_SCHEMA => array(
|
|
'participationStatus' => 'uint32',
|
|
'dateTouched' => 'epoch',
|
|
'seenMessageCount' => 'uint64',
|
|
),
|
|
self::CONFIG_KEY_SCHEMA => array(
|
|
'conpherencePHID' => array(
|
|
'columns' => array('conpherencePHID', 'participantPHID'),
|
|
'unique' => true,
|
|
),
|
|
'unreadCount' => array(
|
|
'columns' => array('participantPHID', 'participationStatus'),
|
|
),
|
|
'participationIndex' => array(
|
|
'columns' => array('participantPHID', 'dateTouched', 'id'),
|
|
),
|
|
),
|
|
) + parent::getConfiguration();
|
|
}
|
|
|
|
public function getSettings() {
|
|
return nonempty($this->settings, array());
|
|
}
|
|
|
|
public function markUpToDate(
|
|
ConpherenceThread $conpherence,
|
|
ConpherenceTransaction $xaction) {
|
|
if (!$this->isUpToDate($conpherence)) {
|
|
$this->setParticipationStatus(ConpherenceParticipationStatus::UP_TO_DATE);
|
|
$this->setBehindTransactionPHID($xaction->getPHID());
|
|
$this->setSeenMessageCount($conpherence->getMessageCount());
|
|
$this->save();
|
|
}
|
|
return $this;
|
|
}
|
|
|
|
private function isUpToDate(ConpherenceThread $conpherence) {
|
|
return
|
|
($this->getSeenMessageCount() == $conpherence->getMessageCount())
|
|
&&
|
|
($this->getParticipationStatus() ==
|
|
ConpherenceParticipationStatus::UP_TO_DATE);
|
|
}
|
|
|
|
}
|