Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/notification/storage/PhabricatorFeedStoryNotification.php
12256 views
1
<?php
2
3
final class PhabricatorFeedStoryNotification extends PhabricatorFeedDAO {
4
5
protected $userPHID;
6
protected $primaryObjectPHID;
7
protected $chronologicalKey;
8
protected $hasViewed;
9
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,
18
),
19
self::CONFIG_KEY_SCHEMA => array(
20
'PRIMARY' => null,
21
'userPHID' => array(
22
'columns' => array('userPHID', 'chronologicalKey'),
23
'unique' => true,
24
),
25
'userPHID_2' => array(
26
'columns' => array('userPHID', 'hasViewed', 'primaryObjectPHID'),
27
),
28
'key_object' => array(
29
'columns' => array('primaryObjectPHID'),
30
),
31
'key_chronological' => array(
32
'columns' => array('chronologicalKey'),
33
),
34
),
35
) + parent::getConfiguration();
36
}
37
38
public static function updateObjectNotificationViews(
39
PhabricatorUser $user,
40
$object_phid) {
41
42
if (PhabricatorEnv::isReadOnly()) {
43
return;
44
}
45
46
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
47
48
$notification_table = new PhabricatorFeedStoryNotification();
49
$conn = $notification_table->establishConnection('w');
50
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);
61
62
unset($unguarded);
63
64
$count_key = PhabricatorUserNotificationCountCacheType::KEY_COUNT;
65
PhabricatorUserCache::clearCache($count_key, $user->getPHID());
66
$user->clearCacheData($count_key);
67
}
68
69
}
70
71