Skip to content

Commit f9e8e2c

Browse files
committed
feat: update libsession-util and update proFeaturesForMessageReturnType
1 parent a97cb6b commit f9e8e2c

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

include/pro/pro.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ std::string_view proBackendEnumToString(SESSION_PRO_BACKEND_PAYMENT_STATUS v);
2020
std::string_view proBackendEnumToString(SESSION_PRO_BACKEND_PLAN v);
2121
std::string_view proBackendEnumToString(SESSION_PRO_BACKEND_USER_PRO_STATUS v);
2222
std::string_view proBackendEnumToString(SESSION_PRO_BACKEND_GET_PRO_STATUS_ERROR_REPORT v);
23+
std::string_view proBackendEnumToString(session::ProFeaturesForMsgStatus v);
2324

2425
template <typename T>
2526
Napi::Value toJsOrNullIfErrors(
@@ -174,7 +175,7 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
174175

175176
auto obj = Napi::Object::New(env);
176177

177-
obj["success"] = toJs(env, pro_features_msg.success);
178+
obj["status"] = toJs(env, proBackendEnumToString(pro_features_msg.status));
178179
obj["error"] =
179180
pro_features_msg.error.size() ? toJs(env, pro_features_msg.error) : env.Null();
180181
obj["codepointCount"] = toJs(env, pro_features_msg.codepoint_count);

src/pro/pro.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,14 @@ std::string_view proBackendEnumPaymentStatusToString(SESSION_PRO_BACKEND_PAYMENT
9595
__builtin_unreachable();
9696
}
9797

98+
std::string_view proBackendEnumToString(session::ProFeaturesForMsgStatus v) {
99+
switch (v) {
100+
case session::ProFeaturesForMsgStatus::Success: return "SUCCESS";
101+
case session::ProFeaturesForMsgStatus::UTFDecodingError: return "UTF_DECODING_ERROR";
102+
case session::ProFeaturesForMsgStatus::ExceedsCharacterLimit:
103+
return "EXCEEDS_CHARACTER_LIMIT";
104+
}
105+
__builtin_unreachable();
106+
}
107+
98108
} // namespace session::nodeapi

types/pro/pro.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ declare module 'libsession_util_nodejs' {
170170
* If provided (here) as an input, it will be ignored.
171171
*/
172172
proFeatures: ProFeatures;
173-
}) => WithProFeatures & { success: boolean; error: string | null; codepointCount: number };
173+
}) => WithProFeatures & {
174+
status: 'SUCCESS' | 'UTF_DECODING_ERROR' | 'EXCEEDS_CHARACTER_LIMIT';
175+
};
174176
proProofRequestBody: (
175177
args: WithMasterPrivKeyHex & WithRequestVersion & WithUnixTsMs & WithRotatingPrivKeyHex
176178
) => string;

0 commit comments

Comments
 (0)