diff --git a/go.mod b/go.mod index c144105f8dc9e36865c3d90a26d3e964aaba239d..715d81268200666e3450cc573932743f5e6e3b4f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.5.0 github.com/spf13/jwalterweatherman v1.1.0 - gitlab.com/elixxir/client/v4 v4.3.12-0.20230228194909-c9c2601830c2 + gitlab.com/elixxir/client/v4 v4.3.12-0.20230228202420-22c4d11f2d7f gitlab.com/elixxir/crypto v0.0.7-0.20230214180106-72841fd1e426 gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c gitlab.com/xx_network/crypto v0.0.5-0.20230214003943-8a09396e95dd diff --git a/go.sum b/go.sum index d8e5148424d8a4eec6a2f9302abde8dbba48e56d..1349e709b84674e7e34ab6626133c9662659bf5b 100644 --- a/go.sum +++ b/go.sum @@ -513,6 +513,8 @@ gitlab.com/elixxir/client/v4 v4.3.12-0.20230228180957-c62cc589d560 h1:wTIZoSxI/W gitlab.com/elixxir/client/v4 v4.3.12-0.20230228180957-c62cc589d560/go.mod h1:Hjx99EdI86q67mHzZVR2Dw37fuTCzDaChM/NVX3CcPU= gitlab.com/elixxir/client/v4 v4.3.12-0.20230228194909-c9c2601830c2 h1:cjObCobCH0IMSMEs57yAboAWPS1v8vpzO0ErHH5s4k8= gitlab.com/elixxir/client/v4 v4.3.12-0.20230228194909-c9c2601830c2/go.mod h1:Hjx99EdI86q67mHzZVR2Dw37fuTCzDaChM/NVX3CcPU= +gitlab.com/elixxir/client/v4 v4.3.12-0.20230228202420-22c4d11f2d7f h1:raZyLq0MSjY33jXg5g2NgFl68LM1JJkAO3+0CHly15c= +gitlab.com/elixxir/client/v4 v4.3.12-0.20230228202420-22c4d11f2d7f/go.mod h1:Hjx99EdI86q67mHzZVR2Dw37fuTCzDaChM/NVX3CcPU= gitlab.com/elixxir/comms v0.0.4-0.20230214180204-3aba2e6795af h1:Eye4+gZEUbOfz4j51WplYD9d7Gnr1s3wKYkEnCfhPaw= gitlab.com/elixxir/comms v0.0.4-0.20230214180204-3aba2e6795af/go.mod h1:ud3s2aHx5zu7lJhBpUMUXxjLwl8PH8z8cl64Om9U7q8= gitlab.com/elixxir/crypto v0.0.7-0.20230214180106-72841fd1e426 h1:O9Xz/ioc9NAj5k/QUsR0W4LCz2uVHawJF89yPTI7NXk= diff --git a/wasm/channels.go b/wasm/channels.go index b2138aa8ca5b809d399efb856708059fc3869d01..3a135cac80d47363118f340a16095a22cd68605d 100644 --- a/wasm/channels.go +++ b/wasm/channels.go @@ -49,6 +49,7 @@ func newChannelsManagerJS(api *bindings.ChannelsManager) map[string]any { "ReplayChannel": js.FuncOf(cm.ReplayChannel), "EnableDirectMessages": js.FuncOf(cm.EnableDirectMessages), "DisableDirectMessages": js.FuncOf(cm.DisableDirectMessages), + "AreDMsEnabled": js.FuncOf(cm.AreDMsEnabled), // Share URL "GetShareURL": js.FuncOf(cm.GetShareURL), @@ -873,6 +874,24 @@ func (cm *ChannelsManager) DisableDirectMessages(_ js.Value, args []js.Value) an return nil } +// AreDMsEnabled returns the status of direct messaging for a given channel. +// +// Parameters: +// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array). +// +// Returns: +// - enabled (bool) - status of dms for passed in channel ID, true if enabled +// - Throws a TypeError if unmarshalling the channel ID +func (cm *ChannelsManager) AreDMsEnabled(_ js.Value, args []js.Value) any { + marshalledChanId := utils.CopyBytesToGo(args[0]) + enabled, err := cm.api.AreDMsEnabled(marshalledChanId) + if err != nil { + utils.Throw(utils.TypeError, err) + return false + } + return enabled +} + //////////////////////////////////////////////////////////////////////////////// // Channel Share URL // ////////////////////////////////////////////////////////////////////////////////