Skip to content

Commit c2793b5

Browse files
committed
fix: memberStatus priority custom enum was incorrect
1 parent f72a970 commit c2793b5

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/groups/meta_group_wrapper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,15 @@ Napi::Value MetaGroupWrapper::memberGetOrConstruct(const Napi::CallbackInfo& inf
429429
});
430430
}
431431

432-
void MetaGroupWrapper::memberConstructAndSet(const Napi::CallbackInfo& info) {
433-
wrapExceptions(info, [&] {
432+
Napi::Value MetaGroupWrapper::memberConstructAndSet(const Napi::CallbackInfo& info) {
433+
return wrapResult(info, [&] {
434434
assertInfoLength(info, 1);
435435
assertIsString(info[0]);
436436

437437
auto pubkeyHex = toCppString(info[0], __PRETTY_FUNCTION__);
438438
auto created = meta_group->members->get_or_construct(pubkeyHex);
439439
meta_group->members->set(created);
440+
return created;
440441
});
441442
}
442443

src/groups/meta_group_wrapper.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ struct toJs_impl<member> {
3535
obj["memberStatus"] = toJs(env, "PROMOTION_NOT_SENT");
3636
} else if (info.invite_status == 0) {
3737
obj["memberStatus"] = toJs(env, "INVITE_ACCEPTED");
38-
} else if (info.invite_pending()) {
39-
obj["memberStatus"] = toJs(env, "INVITE_SENT");
38+
} else if (info.invite_not_sent()) {
39+
obj["memberStatus"] = toJs(env, "INVITE_NOT_SENT");
4040
} else if (info.invite_failed()) {
4141
obj["memberStatus"] = toJs(env, "INVITE_FAILED");
4242
} else {
43-
// this is probably a bad idea to have a catch-all else, but we have to when we consider
44-
// upgrades of libsession-util
45-
obj["memberStatus"] = toJs(env, "INVITE_NOT_SENT");
43+
// Note: INVITE_NOT_SENT is 3, which makes invite_pending() return true, so be sure to
44+
// check for invite_not_sent() above. this is probably a bad idea to have a catch-all
45+
// else, but we have to when we consider upgrades of libsession-util
46+
obj["memberStatus"] = toJs(env, "INVITE_SENT");
4647
}
48+
4749
obj["nominatedAdmin"] = toJs(env, info.admin);
4850

4951
// removed status
@@ -94,7 +96,7 @@ class MetaGroupWrapper : public Napi::ObjectWrap<MetaGroupWrapper> {
9496
Napi::Value memberGetAllPendingRemovals(const Napi::CallbackInfo& info);
9597
Napi::Value memberGet(const Napi::CallbackInfo& info);
9698
Napi::Value memberGetOrConstruct(const Napi::CallbackInfo& info);
97-
void memberConstructAndSet(const Napi::CallbackInfo& info);
99+
Napi::Value memberConstructAndSet(const Napi::CallbackInfo& info);
98100

99101
void memberSetNameTruncated(const Napi::CallbackInfo& info);
100102
void memberSetInvited(const Napi::CallbackInfo& info);

0 commit comments

Comments
 (0)