88#include < span>
99#include < vector>
1010
11+ #include " ../meta/meta_base_wrapper.hpp"
1112#include " ../utilities.hpp"
1213#include " oxen/log.hpp"
1314#include " pro/types.hpp"
1718#include " session/session_protocol.hpp"
1819
1920namespace session ::nodeapi {
21+ namespace log = oxen::log;
2022
2123class ProWrapper : public Napi ::ObjectWrap<ProWrapper> {
24+
2225 public:
2326 ProWrapper (const Napi::CallbackInfo& info) : Napi::ObjectWrap<ProWrapper>{info} {
2427 throw std::invalid_argument (" ProWrapper is static and doesn't need to be constructed" );
@@ -49,6 +52,7 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
4952
5053 assertInfoLength (info, 1 );
5154 assertIsObject (info[0 ]);
55+ auto env = info.Env ();
5256
5357 auto first = info[0 ].As <Napi::Object>();
5458
@@ -67,20 +71,31 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
6771 proFeatures.push_back (item);
6872 }
6973
70- SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags;
74+ SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags = 0 ;
7175 for (std::string& feature : proFeatures) {
72- if (feature == " 10K_CHARACTER_LIMIT" ) {
73- flags |= SESSION_PROTOCOL_PRO_FEATURES_10K_CHARACTER_LIMIT;
74- } else if (feature == " PRO_BADGE" ) {
75- flags |= SESSION_PROTOCOL_PRO_FEATURES_PRO_BADGE;
76+ // Note: 10K_CHARACTER_LIMIT cannot be requested by the caller
77+ if (feature == " PRO_BADGE" ) {
78+ flags |= SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE;
7679 } else if (feature == " ANIMATED_AVATAR" ) {
77- flags |= SESSION_PROTOCOL_PRO_FEATURES_ANIMATED_AVATAR ;
80+ flags |= SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR ;
7881 }
7982 }
8083 assertIsString (first.Get (" utf16" ), " proFeaturesForMessage.utf16" );
8184 std::u16string utf16 = first.Get (" utf16" ).As <Napi::String>().Utf16Value ();
82- return session::pro_features_for_utf16 ((utf16.data ()), utf16.length (), flags);
85+ auto pro_features_msg =
86+ session::pro_features_for_utf16 ((utf16.data ()), utf16.length (), flags);
87+
88+ auto obj = Napi::Object::New (env);
89+
90+ obj[" success" ] = toJs (env, pro_features_msg.success );
91+ obj[" error" ] =
92+ pro_features_msg.error .size () ? toJs (env, pro_features_msg.error ) : env.Null ();
93+ obj[" codepointCount" ] = toJs (env, pro_features_msg.codepoint_count );
94+ obj[" proFeatures" ] = proFeaturesToJs (env, pro_features_msg.features );
95+
96+ return obj;
8397 });
8498 };
8599};
100+
86101}; // namespace session::nodeapi
0 commit comments