@@ -37,6 +37,9 @@ void MetaGroupWrapper::Init(Napi::Env env, Napi::Object exports) {
3737 // members exposed functions
3838 InstanceMethod (" memberGet" , &MetaGroupWrapper::memberGet),
3939 InstanceMethod (" memberGetOrConstruct" , &MetaGroupWrapper::memberGetOrConstruct),
40+ InstanceMethod (
41+ " memberConstructAndSet" , &MetaGroupWrapper::memberConstructAndSet),
42+
4043 InstanceMethod (" memberGetAll" , &MetaGroupWrapper::memberGetAll),
4144 InstanceMethod (
4245 " memberGetAllPendingRemovals" ,
@@ -417,6 +420,17 @@ Napi::Value MetaGroupWrapper::memberGetOrConstruct(const Napi::CallbackInfo& inf
417420 });
418421}
419422
423+ void MetaGroupWrapper::memberConstructAndSet (const Napi::CallbackInfo& info) {
424+ wrapExceptions (info, [&] {
425+ assertInfoLength (info, 1 );
426+ assertIsString (info[0 ]);
427+
428+ auto pubkeyHex = toCppString (info[0 ], __PRETTY_FUNCTION__);
429+ auto created = meta_group->members ->get_or_construct (pubkeyHex);
430+ meta_group->members ->set (created);
431+ });
432+ }
433+
420434void MetaGroupWrapper::memberSetName (const Napi::CallbackInfo& info) {
421435 wrapExceptions (info, [&] {
422436 assertIsString (info[0 ]);
@@ -477,17 +491,17 @@ void MetaGroupWrapper::memberSetPromoted(const Napi::CallbackInfo& info) {
477491}
478492
479493void MetaGroupWrapper::memberSetAdmin (const Napi::CallbackInfo& info) {
480-
481494 wrapExceptions (info, [&] {
482495 assertInfoLength (info, 1 );
483496 assertIsString (info[0 ]);
484497 auto pubkeyHex = toCppString (info[0 ], __PRETTY_FUNCTION__);
485498 // Note: this step might add an admin which was removed back once he accepts the promotion,
486499 // but there is not much we can do about it
487500 auto m = this ->meta_group ->members ->get (pubkeyHex);
488- m->admin = true ;
489-
490- this ->meta_group ->members ->set (*m);
501+ if (m) {
502+ m->admin = true ;
503+ this ->meta_group ->members ->set (*m);
504+ }
491505 });
492506}
493507
@@ -689,6 +703,14 @@ Napi::Value MetaGroupWrapper::loadAdminKeys(const Napi::CallbackInfo& info) {
689703 });
690704}
691705
706+
707+ Napi::Value MetaGroupWrapper::keysAdmin (const Napi::CallbackInfo& info) {
708+ return wrapResult (info, [&] {
709+ assertInfoLength (info, 0 );
710+ return this ->meta_group ->keys ->admin ();
711+ });
712+ }
713+
692714Napi::Value MetaGroupWrapper::generateSupplementKeys (const Napi::CallbackInfo& info) {
693715 return wrapResult (info, [&] {
694716 assertInfoLength (info, 1 );
0 commit comments