Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / notification / storage / PhabricatorFeedStoryNotification.php
blob89d8db53367355afe345c907c2a5db360537d39e
1 <?php
3 final class PhabricatorFeedStoryNotification extends PhabricatorFeedDAO {
5 protected $userPHID;
6 protected $primaryObjectPHID;
7 protected $chronologicalKey;
8 protected $hasViewed;
10 protected function getConfiguration() {
11 return array(
12 self::CONFIG_IDS => self::IDS_MANUAL,
13 self::CONFIG_TIMESTAMPS => false,
14 self::CONFIG_COLUMN_SCHEMA => array(
15 'chronologicalKey' => 'uint64',
16 'hasViewed' => 'bool',
17 'id' => null,
19 self::CONFIG_KEY_SCHEMA => array(
20 'PRIMARY' => null,
21 'userPHID' => array(
22 'columns' => array('userPHID', 'chronologicalKey'),
23 'unique' => true,
25 'userPHID_2' => array(
26 'columns' => array('userPHID', 'hasViewed', 'primaryObjectPHID'),
28 'key_object' => array(
29 'columns' => array('primaryObjectPHID'),
31 'key_chronological' => array(
32 'columns' => array('chronologicalKey'),
35 ) + parent::getConfiguration();
38 public static function updateObjectNotificationViews(
39 PhabricatorUser $user,
40 $object_phid) {
42 if (PhabricatorEnv::isReadOnly()) {
43 return;
46 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
48 $notification_table = new PhabricatorFeedStoryNotification();
49 $conn = $notification_table->establishConnection('w');
51 queryfx(
52 $conn,
53 'UPDATE %T
54 SET hasViewed = 1
55 WHERE userPHID = %s
56 AND primaryObjectPHID = %s
57 AND hasViewed = 0',
58 $notification_table->getTableName(),
59 $user->getPHID(),
60 $object_phid);
62 unset($unguarded);
64 $count_key = PhabricatorUserNotificationCountCacheType::KEY_COUNT;
65 PhabricatorUserCache::clearCache($count_key, $user->getPHID());
66 $user->clearCacheData($count_key);