From fbe4e274fff95150d5d8da0b555635dbea686893 Mon Sep 17 00:00:00 2001 From: Jono Wenger <jono@elixxir.io> Date: Mon, 5 Dec 2022 16:01:53 -0800 Subject: [PATCH] Add GetMutedUsers --- go.mod | 2 +- go.sum | 4 ++-- wasm/channels.go | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9da6c724..a798e8f9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/hack-pad/go-indexeddb v0.2.0 github.com/pkg/errors v0.9.1 github.com/spf13/jwalterweatherman v1.1.0 - gitlab.com/elixxir/client/v4 v4.3.9-0.20221205230100-8d476bdbd896 + gitlab.com/elixxir/client/v4 v4.3.9-0.20221205235846-54146fc90a3e gitlab.com/elixxir/crypto v0.0.7-0.20221202020255-46eeab272a7f gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af gitlab.com/xx_network/crypto v0.0.5-0.20221121220724-8eefdbb0eb46 diff --git a/go.sum b/go.sum index c92a367c..aa0aec4a 100644 --- a/go.sum +++ b/go.sum @@ -369,8 +369,8 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f h1:yXGvNBqzZwAhDYlSnxPRbgor6JWoOt1Z7s3z1O9JR40= gitlab.com/elixxir/bloomfilter v0.0.0-20211222005329-7d931ceead6f/go.mod h1:H6jztdm0k+wEV2QGK/KYA+MY9nj9Zzatux/qIvDDv3k= -gitlab.com/elixxir/client/v4 v4.3.9-0.20221205230100-8d476bdbd896 h1:I/72gteNvOzH1ipt2QxmyQZ8xRrmZHm4yMwffl5T0RY= -gitlab.com/elixxir/client/v4 v4.3.9-0.20221205230100-8d476bdbd896/go.mod h1:6zBHVEOwB42N3Ba3879GW0huu595RLSar04KlNsa7QE= +gitlab.com/elixxir/client/v4 v4.3.9-0.20221205235846-54146fc90a3e h1:rvt+hzzZA4sk1t8Bez7FOxDtjGoCn+ltkJowyzhJieE= +gitlab.com/elixxir/client/v4 v4.3.9-0.20221205235846-54146fc90a3e/go.mod h1:6zBHVEOwB42N3Ba3879GW0huu595RLSar04KlNsa7QE= gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4 h1:bLRjVCyMVde4n2hTVgoyyIAWrKI4CevpChchkPeb6A0= gitlab.com/elixxir/comms v0.0.4-0.20221110181420-84bca6216fe4/go.mod h1:XhI2/CMng+xcH3mAs+1aPz29PSNu1079XMJ8V+xxihw= gitlab.com/elixxir/crypto v0.0.7-0.20221202020255-46eeab272a7f h1:e7h3InxgzRnYOqgUgHrTfK6CW8qNM2SiYRj9tOvsFjA= diff --git a/wasm/channels.go b/wasm/channels.go index 6f733d66..07933ca1 100644 --- a/wasm/channels.go +++ b/wasm/channels.go @@ -64,6 +64,7 @@ func newChannelsManagerJS(api *bindings.ChannelsManager) map[string]any { "DeleteNickname": js.FuncOf(cm.DeleteNickname), "GetNickname": js.FuncOf(cm.GetNickname), "Muted": js.FuncOf(cm.Muted), + "GetMutedUsers": js.FuncOf(cm.GetMutedUsers), "IsChannelAdmin": js.FuncOf(cm.IsChannelAdmin), "ExportChannelAdminKey": js.FuncOf(cm.ExportChannelAdminKey), "VerifyChannelAdminKey": js.FuncOf(cm.VerifyChannelAdminKey), @@ -1302,6 +1303,32 @@ func (cm *ChannelsManager) Muted(_ js.Value, args []js.Value) any { return muted } +// GetMutedUsers returns the list of the public keys for each muted user in +// the channel. If there are no muted user or if the channel does not exist, +// an empty list is returned. +// +// Parameters: +// - args[0] - Marshalled bytes if the channel's [id.ID] (Uint8Array). +// +// Returns: +// - []byte - JSON of []ed25519.PublicKey (Uint8Array). Look below for an +// example. +// - Throws a TypeError if the channel ID cannot be unmarshalled. +// +// Example return: +// +// ["k2IrybDXjJtqxjS6Tx/6m3bXvT/4zFYOJnACNWTvESE=","ocELv7KyeCskLz4cm0klLWhmFLYvQL2FMDco79GTXYw=","mmxoDgoTEYwaRyEzq5Npa24IIs+3B5LXhll/8K5yCv0="] +func (cm *ChannelsManager) GetMutedUsers(_ js.Value, args []js.Value) any { + channelIDBytes := utils.CopyBytesToGo(args[0]) + mutedUsers, err := cm.api.GetMutedUsers(channelIDBytes) + if err != nil { + utils.Throw(utils.TypeError, err) + return nil + } + + return utils.CopyBytesToJS(mutedUsers) +} + //////////////////////////////////////////////////////////////////////////////// // Admin Management // //////////////////////////////////////////////////////////////////////////////// -- GitLab