From acd63438cea948ffb400e13a44b0c232e3a115f6 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 25 Jun 2025 10:28:33 +1000 Subject: [PATCH] fix: logic to clear description with empty string --- package.json | 2 +- src/groups/meta_group_wrapper.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 62659c5..cc4c388 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.4", + "version": "0.5.5", "license": "GPL-3.0", "author": { "name": "Oxen Project", diff --git a/src/groups/meta_group_wrapper.cpp b/src/groups/meta_group_wrapper.cpp index 4df5714..77b703f 100644 --- a/src/groups/meta_group_wrapper.cpp +++ b/src/groups/meta_group_wrapper.cpp @@ -428,9 +428,16 @@ 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); + // Note: maybeNonemptyString returns nullopt when the string is null, undefined or empty. + // in the context of infoSet, `description` is a bit of a custom one as: + // - null/undefined means no change to the current value stored, + // - empty string means set to empty string (i.e. clear it). + // Because of this custom behavior, we need those manual checks in place. + if (auto description = obj.Get("description")) { + if (description.IsString()) { + this->meta_group->info->set_description_truncated( + description.ToString().Utf8Value()); + } } return this->infoGet(info);