Skip to content

feat: wrap group description get/set in infos #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"main": "index.js",
"name": "libsession_util_nodejs",
"description": "Wrappers for the Session Util Library",
"version": "0.5.3",
"version": "0.5.4",
"license": "GPL-3.0",
"author": {
"name": "Oxen Project",
Expand Down
4 changes: 4 additions & 0 deletions src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Napi::Object ConstantsWrapper::Init(Napi::Env env, Napi::Object exports) {
"GROUP_INFO_MAX_NAME_LENGTH",
Napi::Number::New(env, session::config::groups::Info::NAME_MAX_LENGTH),
napi_enumerable),
ObjectWrap::StaticValue(
"GROUP_INFO_DESCRIPTION_MAX_LENGTH",
Napi::Number::New(env, session::config::groups::Info::DESCRIPTION_MAX_LENGTH),
napi_enumerable),
ObjectWrap::StaticValue(
"COMMUNITY_FULL_URL_MAX_LENGTH",
Napi::Number::New(env, session::config::community::FULL_URL_MAX_LENGTH),
Expand Down
6 changes: 6 additions & 0 deletions src/groups/meta_group_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ Napi::Value MetaGroupWrapper::infoGet(const Napi::CallbackInfo& info) {

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

return obj;
});
Expand Down Expand Up @@ -427,6 +428,11 @@ Napi::Value MetaGroupWrapper::infoSet(const Napi::CallbackInfo& info) {
this->meta_group->info->set_profile_pic(profilePic);
}

if (auto description = maybeNonemptyString(
obj.Get("description"), "MetaGroupWrapper::setInfo description")) {
this->meta_group->info->set_description_truncated(*description);
}

return this->infoGet(info);
});
}
Expand Down
6 changes: 6 additions & 0 deletions types/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ declare module 'libsession_util_nodejs' {
deleteBeforeSeconds: number | null;
expirySeconds: number | null;
profilePicture: ProfilePicture | null;
/**
* The group description. Defaults to "" if unset
*/
description: string;
};

export type GroupInfoGet = GroupInfoShared & {
Expand Down Expand Up @@ -151,6 +155,8 @@ declare module 'libsession_util_nodejs' {
BASE_GROUP_MAX_NAME_LENGTH: number;
/** 100 bytes */
GROUP_INFO_MAX_NAME_LENGTH: number;
/** 600 bytes */
GROUP_INFO_DESCRIPTION_MAX_LENGTH: number;
/** 411 bytes
*
* BASE_URL_MAX_LENGTH + '/r/' + ROOM_MAX_LENGTH + qs_pubkey.size() + hex pubkey + null terminator
Expand Down