77#include " ../utilities.hpp"
88#include " ./meta_group.hpp"
99#include " oxenc/bt_producer.h"
10+ #include " session/config/user_groups.hpp"
1011
1112namespace session ::nodeapi {
1213using config::groups::Members;
14+ using session::config::GROUP_DESTROYED;
15+ using session::config::KICKED_FROM_GROUP;
16+ using session::config::NOT_REMOVED;
1317using session::config::groups::member;
1418using session::nodeapi::MetaGroup;
1519
@@ -27,10 +31,10 @@ struct toJs_impl<member> {
2731 // Note: this should be part of `libsession-util`, not `libsession-util-nodejs`
2832 if (info.promoted () && !info.promotion_pending ()) {
2933 obj[" memberStatus" ] = toJs (env, " PROMOTION_ACCEPTED" );
30- } else if (info.promotion_pending ()) {
31- obj[" memberStatus" ] = toJs (env, " PROMOTION_SENT" );
3234 } else if (info.promotion_failed ()) {
3335 obj[" memberStatus" ] = toJs (env, " PROMOTION_FAILED" );
36+ } else if (info.promotion_pending ()) {
37+ obj[" memberStatus" ] = toJs (env, " PROMOTION_SENT" );
3438 } else if (info.admin ) {
3539 obj[" memberStatus" ] = toJs (env, " PROMOTION_NOT_SENT" );
3640 } else if (info.invite_status == 0 ) {
@@ -39,19 +43,25 @@ struct toJs_impl<member> {
3943 obj[" memberStatus" ] = toJs (env, " INVITE_NOT_SENT" );
4044 } else if (info.invite_failed ()) {
4145 obj[" memberStatus" ] = toJs (env, " INVITE_FAILED" );
42- } else {
46+ } else if (info. invite_pending ()) {
4347 // 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
48+ // check for invite_not_sent() above.
4649 obj[" memberStatus" ] = toJs (env, " INVITE_SENT" );
50+ } else {
51+ obj[" memberStatus" ] = toJs (env, " UNKNOWN" );
4752 }
4853
4954 obj[" nominatedAdmin" ] = toJs (env, info.admin );
5055
51- // removed status
52- obj[" isRemoved" ] = toJs (env, info.is_removed ());
53- obj[" shouldRemoveMessages" ] = toJs (env, info.should_remove_messages ());
54-
56+ if (!info.is_removed ()) {
57+ obj[" removedStatus" ] = toJs (env, " NOT_REMOVED" );
58+ } else {
59+ if (info.should_remove_messages ()) {
60+ obj[" removedStatus" ] = toJs (env, " REMOVED_MEMBER_AND_MESSAGES" );
61+ } else {
62+ obj[" removedStatus" ] = toJs (env, " REMOVED_MEMBER" );
63+ }
64+ }
5565 return obj;
5666 }
5767};
0 commit comments