From 2ffa4fd916f8c2904a81ec9ec5f7972a89783e8e Mon Sep 17 00:00:00 2001 From: veselcraft Date: Mon, 13 Mar 2023 17:45:45 +0300 Subject: [PATCH] VKAPI: Add force online activity reporting on Newsfeed.get and Messages.send functions (can be disabled trough forGodSakePleaseDoNotReportAboutMyOnlineActivity parameter) --- VKAPI/Handlers/Account.php | 4 +--- VKAPI/Handlers/Messages.php | 9 +++++++-- VKAPI/Handlers/Newsfeed.php | 7 ++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/VKAPI/Handlers/Account.php b/VKAPI/Handlers/Account.php index 275c50f4..dd6cfa7b 100644 --- a/VKAPI/Handlers/Account.php +++ b/VKAPI/Handlers/Account.php @@ -45,9 +45,7 @@ final class Account extends VKAPIRequestHandler { $this->requireUser(); - $this->getUser()->setOnline(time()); - $this->getUser()->setClient_name($this->getPlatform()); - $this->getUser()->save(); + $this->getUser()->updOnline($this->getPlatform()); return 1; } diff --git a/VKAPI/Handlers/Messages.php b/VKAPI/Handlers/Messages.php index ead8e273..bc9035f5 100644 --- a/VKAPI/Handlers/Messages.php +++ b/VKAPI/Handlers/Messages.php @@ -65,11 +65,16 @@ final class Messages extends VKAPIRequestHandler ]; } - function send(int $user_id = -1, int $peer_id = -1, string $domain = "", int $chat_id = -1, string $user_ids = "", string $message = "", int $sticker_id = -1) + function send(int $user_id = -1, int $peer_id = -1, string $domain = "", int $chat_id = -1, string $user_ids = "", string $message = "", int $sticker_id = -1, int $forGodSakePleaseDoNotReportAboutMyOnlineActivity = 0) { $this->requireUser(); $this->willExecuteWriteAction(); - + + if($forGodSakePleaseDoNotReportAboutMyOnlineActivity == 0) + { + $this->getUser()->updOnline($this->getPlatform()); + } + if($chat_id !== -1) $this->fail(946, "Chats are not implemented"); else if($sticker_id !== -1) diff --git a/VKAPI/Handlers/Newsfeed.php b/VKAPI/Handlers/Newsfeed.php index 5451f449..16bd3123 100644 --- a/VKAPI/Handlers/Newsfeed.php +++ b/VKAPI/Handlers/Newsfeed.php @@ -7,9 +7,14 @@ use openvk\VKAPI\Handlers\Wall; final class Newsfeed extends VKAPIRequestHandler { - function get(string $fields = "", int $start_from = 0, int $offset = 0, int $count = 30, int $extended = 0) + function get(string $fields = "", int $start_from = 0, int $offset = 0, int $count = 30, int $extended = 0, int $forGodSakePleaseDoNotReportAboutMyOnlineActivity = 0) { $this->requireUser(); + + if($forGodSakePleaseDoNotReportAboutMyOnlineActivity == 0) + { + $this->getUser()->updOnline($this->getPlatform()); + } $id = $this->getUser()->getId(); $subs = DatabaseConnection::i()