7
7
#include " ../utilities.hpp"
8
8
#include " ./meta_group.hpp"
9
9
#include " oxenc/bt_producer.h"
10
+ #include " session/config/user_groups.hpp"
10
11
11
12
namespace session ::nodeapi {
12
13
using config::groups::Members;
14
+ using session::config::GROUP_DESTROYED;
15
+ using session::config::KICKED_FROM_GROUP;
16
+ using session::config::NOT_REMOVED;
13
17
using session::config::groups::member;
14
18
using session::nodeapi::MetaGroup;
15
19
@@ -27,10 +31,10 @@ struct toJs_impl<member> {
27
31
// Note: this should be part of `libsession-util`, not `libsession-util-nodejs`
28
32
if (info.promoted () && !info.promotion_pending ()) {
29
33
obj[" memberStatus" ] = toJs (env, " PROMOTION_ACCEPTED" );
30
- } else if (info.promotion_pending ()) {
31
- obj[" memberStatus" ] = toJs (env, " PROMOTION_SENT" );
32
34
} else if (info.promotion_failed ()) {
33
35
obj[" memberStatus" ] = toJs (env, " PROMOTION_FAILED" );
36
+ } else if (info.promotion_pending ()) {
37
+ obj[" memberStatus" ] = toJs (env, " PROMOTION_SENT" );
34
38
} else if (info.admin ) {
35
39
obj[" memberStatus" ] = toJs (env, " PROMOTION_NOT_SENT" );
36
40
} else if (info.invite_status == 0 ) {
@@ -39,19 +43,25 @@ struct toJs_impl<member> {
39
43
obj[" memberStatus" ] = toJs (env, " INVITE_NOT_SENT" );
40
44
} else if (info.invite_failed ()) {
41
45
obj[" memberStatus" ] = toJs (env, " INVITE_FAILED" );
42
- } else {
46
+ } else if (info. invite_pending ()) {
43
47
// 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.
46
49
obj[" memberStatus" ] = toJs (env, " INVITE_SENT" );
50
+ } else {
51
+ obj[" memberStatus" ] = toJs (env, " UNKNOWN" );
47
52
}
48
53
49
54
obj[" nominatedAdmin" ] = toJs (env, info.admin );
50
55
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
+ }
55
65
return obj;
56
66
}
57
67
};
0 commit comments