diff --git a/package.json b/package.json index 1bfcbf1..62659c5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/constants.cpp b/src/constants.cpp index 2514a1d..a47ca65 100644 --- a/src/constants.cpp +++ b/src/constants.cpp @@ -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), diff --git a/src/groups/meta_group_wrapper.cpp b/src/groups/meta_group_wrapper.cpp index e85edec..4df5714 100644 --- a/src/groups/meta_group_wrapper.cpp +++ b/src/groups/meta_group_wrapper.cpp @@ -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; }); @@ -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); }); } diff --git a/types/shared.d.ts b/types/shared.d.ts index b2890ca..50b06d4 100644 --- a/types/shared.d.ts +++ b/types/shared.d.ts @@ -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 & { @@ -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