Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3378564
D5210.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5210.diff
View Options
diff --git a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
--- a/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
+++ b/services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
@@ -8,6 +8,9 @@
#include "GlobalTools.h"
#include "Tools.h"
+#include "rust-notifications/src/lib.rs.h"
+#include "rust/cxx.h"
+
#include <glog/logging.h>
namespace comm {
@@ -140,6 +143,8 @@
}
const std::string clientDeviceID = sessionItem->getDeviceID();
const std::string messageID = tools::generateUUID();
+ const std::string notifyToken = sessionItem->getNotifyToken();
+ const std::string deviceOs = sessionItem->getDeviceOs();
const database::MessageItem message(
messageID,
@@ -155,6 +160,46 @@
grpc::StatusCode::INTERNAL,
"Error while publish the message to AMQP");
}
+
+ if (!sessionItem->getIsOnline()) {
+ const std::string notificationMessageTitle = "New message";
+ const std::string notificationMessageText = "You have a new message";
+ if (deviceOs == "iOS" && !notifyToken.empty()) {
+ const apnsReturnStatus apnsResult = sendNotifToAPNS(
+ config::ConfigManager::getInstance().getParameter(
+ config::ConfigManager::OPTION_NOTIFS_APNS_P12_CERT_PATH),
+ config::ConfigManager::getInstance().getParameter(
+ config::ConfigManager::OPTION_NOTIFS_APNS_P12_CERT_PASSWORD),
+ notifyToken,
+ config::ConfigManager::getInstance().getParameter(
+ config::ConfigManager::OPTION_NOTIFS_APNS_TOPIC),
+ notificationMessageText,
+ false);
+ if ((apnsResult == apnsReturnStatus::Unregistered ||
+ apnsResult == apnsReturnStatus::BadDeviceToken) &&
+ !database::DatabaseManager::getInstance()
+ .updateSessionItemDeviceToken(sessionID, "")) {
+ return grpc::Status(
+ grpc::StatusCode::INTERNAL,
+ "Can't clear the device token in database");
+ }
+ } else if (deviceOs == "Android" && !notifyToken.empty()) {
+ const fcmReturnStatus fcmResult = sendNotifToFCM(
+ config::ConfigManager::getInstance().getParameter(
+ config::ConfigManager::OPTION_NOTIFS_FCM_SERVER_KEY),
+ notifyToken,
+ notificationMessageTitle,
+ notificationMessageText);
+ if ((fcmResult == fcmReturnStatus::InvalidRegistration ||
+ fcmResult == fcmReturnStatus::NotRegistered) &&
+ !database::DatabaseManager::getInstance()
+ .updateSessionItemDeviceToken(sessionID, "")) {
+ return grpc::Status(
+ grpc::StatusCode::INTERNAL,
+ "Can't clear the device token in database");
+ }
+ }
+ }
} catch (std::runtime_error &e) {
LOG(ERROR) << "gRPC: "
<< "Error while processing 'Send' request: " << e.what();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 11:34 AM (21 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2593873
Default Alt Text
D5210.diff (2 KB)
Attached To
Mode
D5210: [services] Tunnelbroker - Updating `Send` handler with using of the Rust notification library
Attached
Detach File
Event Timeline
Log In to Comment