Skip to content

Commit 5712c5a

Browse files
feat: add by app, by code and by license plate number tracking events
1 parent bfd6ad6 commit 5712c5a

6 files changed

Lines changed: 63 additions & 11 deletions

File tree

server/backends/households/internal/internal.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3852,8 +3852,34 @@ function paranoidEvent() {
38523852

38533853
$paranoids = false;
38543854

3855+
$map_event_type = [
3856+
"rfId" => [
3857+
"event_type" => "3",
3858+
"title" => "mobile.paranoidTitleRf",
3859+
"message" => "mobile.paranoidMsgRf",
3860+
],
3861+
"app" => [
3862+
"event_type" => "4",
3863+
"title" => "mobile.paranoidTitleApp",
3864+
"message" => "mobile.paranoidMsgApp",
3865+
],
3866+
"code" => [
3867+
"event_type" => "6",
3868+
"title" => "mobile.paranoidTitleCode",
3869+
"message" => "mobile.paranoidMsgCode",
3870+
],
3871+
"lp" => [
3872+
"event_type" => "9",
3873+
"title" => "mobile.paranoidTitleLP",
3874+
"message" => "mobile.paranoidMsgLP",
3875+
],
3876+
];
3877+
38553878
switch ($by) {
38563879
case "rfId":
3880+
case "app":
3881+
case "code":
3882+
case "lp":
38573883
$paranoids = $this->db->get("
38583884
select * from (
38593885
select
@@ -3862,24 +3888,25 @@ function paranoidEvent() {
38623888
houses_subscribers_devices.push_token,
38633889
houses_subscribers_devices.push_token_type,
38643890
houses_subscribers_devices.ua,
3865-
houses_watchers.comments
3891+
coalesce(houses_watchers.comments, '') comments
38663892
from
38673893
houses_watchers
38683894
left join
38693895
houses_flats on houses_flats.house_flat_id = houses_watchers.house_flat_id
38703896
left join
38713897
houses_subscribers_devices on houses_subscribers_devices.subscriber_device_id = houses_watchers.subscriber_device_id
38723898
where
3873-
event_type = '3' and
3874-
event_detail = :rfid and
3899+
event_type = :event_type and
3900+
(event_detail = :detail or coalesce(event_detail, '') = '') and
38753901
houses_watchers.house_flat_id in (
38763902
select house_flat_id from houses_entrances_flats where house_entrance_id = :house_entrance_id
38773903
)
38783904
) as t
38793905
group by
38803906
address_house_id, platform, push_token, push_token_type, ua, comments
38813907
", [
3882-
"rfid" => $detail,
3908+
"event_type" => $map_event_type[$by]["event_type"],
3909+
"detail" => $detail,
38833910
"house_entrance_id" => $entrance["entranceId"]
38843911
], [
38853912
"address_house_id" => "houseId",
@@ -3930,8 +3957,8 @@ function paranoidEvent() {
39303957
"timestamp" => time(),
39313958
"ttl" => 90,
39323959
"platform" => [ "android", "ios", "web" ][(int)$paranoid["platform"]],
3933-
"title" => i18nL($l, "mobile.paranoidTitleRf"),
3934-
"msg" => i18nL($l, "mobile.paranoidMsgRf", $house["houseFull"], $entrance["callerId"], $paranoid["comments"] ?: $detail),
3960+
"title" => i18nL($l, $map_event_type[$by]["title"]),
3961+
"msg" => i18nL($l, $map_event_type[$by]["message"], $house["houseFull"], $entrance["callerId"], $paranoid["comments"] ?: $detail),
39353962
"houseId" => $paranoid["houseId"],
39363963
"hash" => $hash,
39373964
"sound" => "default",

server/i18n/en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
"pinError": "The PIN code was entered incorrectly",
5757
"paranoidTitleRf": "Door opened by rfId",
5858
"paranoidMsgRf": "%s, %s opened by rfId \"%s\"",
59+
"paranoidTitleApp": "Door opened from app",
60+
"paranoidMsgApp": "%s, %s opened from app by user \"%s\"",
61+
"paranoidTitleCode": "Door opened by code",
62+
"paranoidMsgCode": "%s, %s opened by code \"%s\"",
63+
"paranoidTitleLP": "Entrance opened by license plate number",
64+
"paranoidMsgLP": "%s, %s opened by \"%s\"",
5965
"overLimit": "Device limit per mobile number exceeded",
6066
"contactProviderForAdding": "Please contact your provider or flat owner",
6167
"invalidPlateNumber": "Invalid license plate number"

server/i18n/ru.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@
5555
"maxAttempts": "Превышено максимальное число попыток ввода",
5656
"pinError": "Пин-код введен неверно",
5757
"paranoidTitleRf": "Открытие двери по ключу",
58-
"paranoidMsgRf": "%s, %s открыта ключoм \"%s\"",
58+
"paranoidMsgRf": "%s, %s открыта ключом \"%s\"",
59+
"paranoidTitleApp": "Открытие двери из приложения",
60+
"paranoidMsgApp": "%s, %s открыта из приложения пользователем \"%s\"",
61+
"paranoidTitleCode": "Открытие двери по коду",
62+
"paranoidMsgCode": "%s, %s открыта кодом \"%s\"",
63+
"paranoidTitleLP": "Открытие въезда по номеру автомобиля",
64+
"paranoidMsgLP": "%s, %s открыт по номеру \"%s\"",
5965
"overLimit": "Превышен лимит устройств на мобильный номер",
6066
"contactProviderForAdding": "Для добавление телефона, обратитесь к вашему провайдеру или владельцу квартиры",
6167
"invalidPlateNumber": "Некорректный автомобильный номер"

server/internal/actions/openDoor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@
8383
// Add door open data
8484
$plogDoorOpen = $plog->addDoorOpenData($date, $ip, $subId, $event, $door, $detail);
8585

86-
// TODO: paranoidEvent (pushes)
87-
// $households->paranoidEvent($entranceId, "code", $details);
86+
// paranoidEvent (pushes)
87+
$households = loadBackend('households');
88+
$households->paranoidEvent($ip, $subId, $door, "code", $detail);
8889

8990
response(201, ["id" => $plogDoorOpen]);
9091

server/internal/lprs/callback.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ function openDoor($entrance): void
104104
$flats_with_event[] = $value;
105105
$plog->addDoorOpenDataById(time(), $domophone_id, plog::EVENT_OPENED_BY_VEHICLE, $domophone_output,
106106
$number . "|" . $value . "|" . $event_id . "|" . $camera_id);
107+
108+
// paranoidEvent (pushes)
109+
$households->paranoidEvent($entrance["entranceId"], "lp", $number);
107110
}
108111
}
109112
}

server/mobile/address/openDoor.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
$domophone_id = (int)@$postdata['domophoneId'];
2626
$door_id = (int)@$postdata['doorId'];
2727
$households = loadBackend("households");
28+
$entrance_id = null;
2829

2930
// Check intercom is blocking
3031
$blocked = true;
@@ -40,6 +41,7 @@
4041
$doorId = intval($e['domophoneOutput']);
4142
if ($domophone_id == $domophoneId && $door_id == $doorId && !$flatDetail['manualBlock'] ) {
4243
$blocked = false;
44+
$entrance_id = $entrance['entranceId'];
4345
break;
4446
}
4547
}
@@ -77,6 +79,11 @@
7779

7880
if ($plog) {
7981
$plog->addDoorOpenDataById(time(), $domophone_id, $plog::EVENT_OPENED_BY_APP, $door_id, $subscriber['mobile']);
82+
83+
// paranoidEvent (pushes)
84+
if (isset($entrance_id)) {
85+
$households->paranoidEvent($entrance_id, "app", $subscriber['mobile']);
86+
}
8087
}
8188

8289
response();
@@ -90,8 +97,10 @@
9097
if ($plog) {
9198
$plog->addDoorOpenDataById(time(), $domophone_id, $plog::EVENT_OPENED_BY_APP, $door_id, $subscriber['mobile']);
9299

93-
// TODO: paranoidEvent (pushes)
94-
// $households->paranoidEvent($entranceId, "code", $details);
100+
// paranoidEvent (pushes)
101+
if (isset($entrance_id)) {
102+
$households->paranoidEvent($entrance_id, "app", $subscriber['mobile']);
103+
}
95104
}
96105
} catch (Exception $e) {
97106
response(404, false, i18n('mobile.error'), i18n('mobile.unavailable'));

0 commit comments

Comments
 (0)