Skip to content

Commit f94e468

Browse files
authored
Merge pull request #28 from Bilb/feat-add-group-description
feat: wrap group description get/set in infos
2 parents f9db679 + d87d354 commit f94e468

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "index.js",
33
"name": "libsession_util_nodejs",
44
"description": "Wrappers for the Session Util Library",
5-
"version": "0.5.3",
5+
"version": "0.5.4",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Project",

src/constants.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Napi::Object ConstantsWrapper::Init(Napi::Env env, Napi::Object exports) {
2929
"GROUP_INFO_MAX_NAME_LENGTH",
3030
Napi::Number::New(env, session::config::groups::Info::NAME_MAX_LENGTH),
3131
napi_enumerable),
32+
ObjectWrap::StaticValue(
33+
"GROUP_INFO_DESCRIPTION_MAX_LENGTH",
34+
Napi::Number::New(env, session::config::groups::Info::DESCRIPTION_MAX_LENGTH),
35+
napi_enumerable),
3236
ObjectWrap::StaticValue(
3337
"COMMUNITY_FULL_URL_MAX_LENGTH",
3438
Napi::Number::New(env, session::config::community::FULL_URL_MAX_LENGTH),

src/groups/meta_group_wrapper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ Napi::Value MetaGroupWrapper::infoGet(const Napi::CallbackInfo& info) {
389389

390390
obj["isDestroyed"] = toJs(env, this->meta_group->info->is_destroyed());
391391
obj["profilePicture"] = toJs(env, this->meta_group->info->get_profile_pic());
392+
obj["description"] = toJs(env, this->meta_group->info->get_description().value_or(""));
392393

393394
return obj;
394395
});
@@ -427,6 +428,11 @@ Napi::Value MetaGroupWrapper::infoSet(const Napi::CallbackInfo& info) {
427428
this->meta_group->info->set_profile_pic(profilePic);
428429
}
429430

431+
if (auto description = maybeNonemptyString(
432+
obj.Get("description"), "MetaGroupWrapper::setInfo description")) {
433+
this->meta_group->info->set_description_truncated(*description);
434+
}
435+
430436
return this->infoGet(info);
431437
});
432438
}

types/shared.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ declare module 'libsession_util_nodejs' {
122122
deleteBeforeSeconds: number | null;
123123
expirySeconds: number | null;
124124
profilePicture: ProfilePicture | null;
125+
/**
126+
* The group description. Defaults to "" if unset
127+
*/
128+
description: string;
125129
};
126130

127131
export type GroupInfoGet = GroupInfoShared & {
@@ -151,6 +155,8 @@ declare module 'libsession_util_nodejs' {
151155
BASE_GROUP_MAX_NAME_LENGTH: number;
152156
/** 100 bytes */
153157
GROUP_INFO_MAX_NAME_LENGTH: number;
158+
/** 600 bytes */
159+
GROUP_INFO_DESCRIPTION_MAX_LENGTH: number;
154160
/** 411 bytes
155161
*
156162
* BASE_URL_MAX_LENGTH + '/r/' + ROOM_MAX_LENGTH + qs_pubkey.size() + hex pubkey + null terminator

0 commit comments

Comments
 (0)