Skip to content

Commit feb95ce

Browse files
committed
feat: we return the user profile name when setUserInfo is called
since we now truncate by default we need to give session-desktop access to the truncated name result
1 parent 032ce31 commit feb95ce

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/user_config.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Napi::Value UserConfigWrapper::getUserInfo(const Napi::CallbackInfo& info) {
5555
});
5656
}
5757

58-
void UserConfigWrapper::setUserInfo(const Napi::CallbackInfo& info) {
59-
wrapExceptions(info, [&] {
58+
Napi::Value UserConfigWrapper::setUserInfo(const Napi::CallbackInfo& info) {
59+
return wrapResult(info, [&] {
6060
assertInfoLength(info, 3);
6161

6262
auto name = info[0];
@@ -79,6 +79,8 @@ void UserConfigWrapper::setUserInfo(const Napi::CallbackInfo& info) {
7979
assertIsObject(profile_pic_obj);
8080

8181
config.set_profile_pic(profile_pic_from_object(profile_pic_obj));
82+
83+
return config.get_name();
8284
});
8385
}
8486

src/user_config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class UserConfigWrapper : public ConfigBaseImpl, public Napi::ObjectWrap<UserCon
1818
config::UserProfile& config{get_config<config::UserProfile>()};
1919

2020
Napi::Value getUserInfo(const Napi::CallbackInfo& info);
21-
void setUserInfo(const Napi::CallbackInfo& info);
21+
Napi::Value setUserInfo(const Napi::CallbackInfo& info);
2222

2323
Napi::Value getEnableBlindedMsgRequest(const Napi::CallbackInfo& info);
2424
void setEnableBlindedMsgRequest(const Napi::CallbackInfo& info);

user/userconfig.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ declare module 'libsession_util_nodejs' {
1515
url: string;
1616
key: Uint8Array;
1717
};
18+
/** if name > CONTACT_MAX_NAME_LENGTH it will be truncated */
1819
setUserInfo: (
1920
name: string,
2021
priority: number,
2122
profilePic: { url: string; key: Uint8Array } | null
22-
) => void;
23+
) => string;
2324
setEnableBlindedMsgRequest: (msgRequest: boolean) => void;
2425
getEnableBlindedMsgRequest: () => boolean | undefined;
2526
setNoteToSelfExpiry: (expirySeconds: number) => void;

0 commit comments

Comments
 (0)