diff --git a/bin/nodejs/callback.h b/bin/nodejs/callback.h index f1e3072e3b9b40bdb627a05f8196379da718f28e..325cba491bf75891ccbaf9e7da49bf85db1bed4f 100644 --- a/bin/nodejs/callback.h +++ b/bin/nodejs/callback.h @@ -55,6 +55,7 @@ Persistent<Function> messageSendCb; Persistent<Function> accountProfileReceivedCb; Persistent<Function> profileReceivedCb; Persistent<Function> userSearchEndedCb; +Persistent<Function> deviceRevocationEndedCb; std::queue<std::function<void()>> pendingSignals; std::mutex pendingSignalsLock; @@ -156,6 +157,8 @@ getPresistentCb(std::string_view signal) return &profileReceivedCb; else if (signal == "UserSearchEnded") return &userSearchEndedCb; + else if (signal == "DeviceRevocationEnded") + return &deviceRevocationEndedCb; else return nullptr; } @@ -577,6 +580,23 @@ userSearchEnded(const std::string& accountId,int state, const std::string& query uv_async_send(&signalAsync); } +void +deviceRevocationEnded(const std::string& accountId,const std::string& device, int status) +{ + std::lock_guard lock(pendingSignalsLock); + pendingSignals.emplace([accountId,device, status]() { + Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), deviceRevocationEndedCb); + if (!func.IsEmpty()) { + SWIGV8_VALUE callback_args[] = {V8_STRING_NEW_LOCAL(accountId), + V8_STRING_NEW_LOCAL(device), + SWIGV8_INTEGER_NEW(status)}; + func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 3, callback_args); + } + }); + + uv_async_send(&signalAsync); +} + void incomingTrustRequest(const std::string& accountId, const std::string& from,