Skip to content

Commit 945b66d

Browse files
committed
feat: add keys for group when provided for easier debugging
1 parent 737a3e4 commit 945b66d

File tree

4 files changed

+13
-45
lines changed

4 files changed

+13
-45
lines changed

src/groups/meta_group.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class MetaGroup {
3434
shared_ptr<config::groups::Keys> keys,
3535
session::ustring edGroupPubKey,
3636
std::optional<session::ustring> edGroupSecKey) :
37-
info{info}, members{members}, keys{keys} {
38-
39-
this->edGroupPubKey = oxenc::to_hex(edGroupPubKey);
40-
this->edGroupSecKey = edGroupSecKey ? oxenc::to_hex(*edGroupSecKey) : nullptr;
41-
};
42-
43-
explicit MetaGroup(const Napi::CallbackInfo& info) {}
37+
info{info}, members{members}, keys{keys}, edGroupPubKey{oxenc::to_hex(edGroupPubKey)} {
38+
39+
if (edGroupSecKey.has_value()) {
40+
this->edGroupSecKey = oxenc::to_hex(*edGroupSecKey);
41+
} else {
42+
this->edGroupSecKey = std::nullopt;
43+
}
44+
}
4445
};
45-
46-
} // namespace session::nodeapi
46+
} // namespace session::nodeapi

src/groups/meta_group_wrapper.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,7 @@ namespace session::nodeapi {
1111

1212
MetaGroupWrapper::MetaGroupWrapper(const Napi::CallbackInfo& info) :
1313
meta_group{std::move(MetaBaseWrapper::constructGroupWrapper(info, "MetaGroupWrapper"))},
14-
Napi::ObjectWrap<MetaGroupWrapper>{info} {
15-
auto env = info.Env();
16-
// this->meta_group->members->logger = [env](session::config::LogLevel, std::string_view x) {
17-
// std::string toLog = "libsession-util:MetaGroup:Member: " + std::string(x) + "\n";
18-
19-
// Napi::Function consoleLog =
20-
// env.Global().Get("console").As<Napi::Object>().Get("log").As<Napi::Function>();
21-
// consoleLog.Call({Napi::String::New(env, toLog)});
22-
// };
23-
// this->meta_group->info->logger = [env](session::config::LogLevel, std::string_view x) {
24-
// std::string toLog = "libsession-util:MetaGroup:Info: " + std::string(x) + "\n";
25-
26-
// Napi::Function consoleLog =
27-
// env.Global().Get("console").As<Napi::Object>().Get("log").As<Napi::Function>();
28-
// consoleLog.Call({Napi::String::New(env, toLog)});
29-
// };
30-
// this->meta_group->keys->logger = [env](
31-
// session::config::LogLevel,
32-
// std::string_view x) {
33-
// std::string toLog = "libsession-util:MetaGroup:Keys: " + std::string(x) + "\n";
34-
35-
// Napi::Function consoleLog =
36-
// env.Global().Get("console").As<Napi::Object>().Get("log").As<Napi::Function>();
37-
// consoleLog.Call({Napi::String::New(env, toLog)});
38-
// };
39-
}
14+
Napi::ObjectWrap<MetaGroupWrapper>{info} {}
4015

4116
void MetaGroupWrapper::Init(Napi::Env env, Napi::Object exports) {
4217
MetaBaseWrapper::NoBaseClassInitHelper<MetaGroupWrapper>(
@@ -152,8 +127,6 @@ Napi::Value MetaGroupWrapper::needsDump(const Napi::CallbackInfo& info) {
152127

153128
Napi::Value MetaGroupWrapper::metaDump(const Napi::CallbackInfo& info) {
154129
return wrapResult(info, [&] {
155-
auto env = info.Env();
156-
157130
oxenc::bt_dict_producer combined;
158131

159132
// NOTE: the keys have to be in ascii-sorted order:
@@ -168,8 +141,6 @@ Napi::Value MetaGroupWrapper::metaDump(const Napi::CallbackInfo& info) {
168141

169142
Napi::Value MetaGroupWrapper::metaMakeDump(const Napi::CallbackInfo& info) {
170143
return wrapResult(info, [&] {
171-
auto env = info.Env();
172-
173144
oxenc::bt_dict_producer combined;
174145

175146
// NOTE: the keys have to be in ascii-sorted order:
@@ -192,7 +163,6 @@ void MetaGroupWrapper::metaConfirmPushed(const Napi::CallbackInfo& info) {
192163

193164
auto groupInfo = obj.Get("groupInfo");
194165
auto groupMember = obj.Get("groupMember");
195-
auto groupKeys = obj.Get("groupKeys");
196166

197167
if (!groupInfo.IsNull() && !groupInfo.IsUndefined()) {
198168
assertIsArray(groupInfo);
@@ -429,7 +399,6 @@ Napi::Value MetaGroupWrapper::memberGetAllPendingRemovals(const Napi::CallbackIn
429399

430400
Napi::Value MetaGroupWrapper::memberGet(const Napi::CallbackInfo& info) {
431401
return wrapResult(info, [&] {
432-
auto env = info.Env();
433402
assertInfoLength(info, 1);
434403
assertIsString(info[0]);
435404

@@ -440,7 +409,6 @@ Napi::Value MetaGroupWrapper::memberGet(const Napi::CallbackInfo& info) {
440409

441410
Napi::Value MetaGroupWrapper::memberGetOrConstruct(const Napi::CallbackInfo& info) {
442411
return wrapResult(info, [&] {
443-
auto env = info.Env();
444412
assertInfoLength(info, 1);
445413
assertIsString(info[0]);
446414

@@ -475,7 +443,6 @@ Napi::Value MetaGroupWrapper::memberSetInvited(const Napi::CallbackInfo& info) {
475443
this->meta_group->members->set(m);
476444

477445
return this->meta_group->members->get_or_construct(pubkeyHex);
478-
479446
});
480447
}
481448

src/meta/meta_base_wrapper.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class MetaBaseWrapper {
6868
std::optional<ustring_view> dumped_keys;
6969

7070
if (dumped_meta) {
71+
7172
auto dumped_meta_str = from_unsigned_sv(*dumped_meta);
7273

7374
oxenc::bt_dict_consumer combined{dumped_meta_str};
@@ -101,7 +102,8 @@ class MetaBaseWrapper {
101102
*info,
102103
*members);
103104

104-
return std::make_unique<session::nodeapi::MetaGroup>(info, members, keys,group_ed25519_pubkey, group_ed25519_secretkey);
105+
return std::make_unique<session::nodeapi::MetaGroup>(
106+
info, members, keys, group_ed25519_pubkey, group_ed25519_secretkey);
105107
});
106108
}
107109
};

src/utilities.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <type_traits>
99
#include <unordered_set>
1010
#include <vector>
11-
#include <stdexcept>
1211

1312
#include "session/config/namespaces.hpp"
1413
#include "session/types.hpp"

0 commit comments

Comments
 (0)