Skip to content
Snippets Groups Projects
Commit 0f2906c1 authored by Jonah Husson's avatar Jonah Husson
Browse files

Merge branch 'xx-4506/enableDMBindings' into 'release'

Add bindings to enable DMs

See merge request !73
parents 8c94b1d4 9d564f19
No related branches found
No related tags found
2 merge requests!73Add bindings to enable DMs,!67fix for latest client release
......@@ -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.20230224195602-fb6cdfb3e795
gitlab.com/elixxir/client/v4 v4.3.12-0.20230228173442-a9ee1c81b8b1
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
......
......@@ -515,6 +515,8 @@ gitlab.com/elixxir/client/v4 v4.3.12-0.20230222164944-6db1a3003e3c h1:8906s8e8QZ
gitlab.com/elixxir/client/v4 v4.3.12-0.20230222164944-6db1a3003e3c/go.mod h1:Hjx99EdI86q67mHzZVR2Dw37fuTCzDaChM/NVX3CcPU=
gitlab.com/elixxir/client/v4 v4.3.12-0.20230224195602-fb6cdfb3e795 h1:WxL57QmpRY2c20539xjtKSbHS+JN1U3inYYz6lJeRFU=
gitlab.com/elixxir/client/v4 v4.3.12-0.20230224195602-fb6cdfb3e795/go.mod h1:Hjx99EdI86q67mHzZVR2Dw37fuTCzDaChM/NVX3CcPU=
gitlab.com/elixxir/client/v4 v4.3.12-0.20230228173442-a9ee1c81b8b1 h1:wYid4FUcWd8Bszl8vE4ED8FD5ZbLi4f8PGXz/32Phis=
gitlab.com/elixxir/client/v4 v4.3.12-0.20230228173442-a9ee1c81b8b1/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=
......
......@@ -47,6 +47,8 @@ func newChannelsManagerJS(api *bindings.ChannelsManager) map[string]any {
"GetChannels": js.FuncOf(cm.GetChannels),
"LeaveChannel": js.FuncOf(cm.LeaveChannel),
"ReplayChannel": js.FuncOf(cm.ReplayChannel),
"EnableDirectMessages": js.FuncOf(cm.EnableDirectMessages),
"DisableDirectMessages": js.FuncOf(cm.DisableDirectMessages),
// Share URL
"GetShareURL": js.FuncOf(cm.GetShareURL),
......@@ -402,6 +404,7 @@ func NewChannelsManagerWithIndexedDb(_ js.Value, args []js.Value) any {
// Returns a promise:
// - Resolves to a Javascript representation of the [ChannelsManager] object.
// - Rejected with an error if loading indexedDb or the manager fails.
//
// FIXME: package names in comments for indexedDb
func NewChannelsManagerWithIndexedDbUnsafe(_ js.Value, args []js.Value) any {
cmixID := args[0].Int()
......@@ -825,6 +828,42 @@ func (cm *ChannelsManager) GetChannels(js.Value, []js.Value) any {
return utils.CopyBytesToJS(channelList)
}
// EnableDirectMessages enables the token for direct messaging for this
// channel.
//
// Parameters:
// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array).
//
// Returns:
// - Throws a TypeError if saving the DM token fails.
func (cm *ChannelsManager) EnableDirectMessages(_ js.Value, args []js.Value) any {
marshalledChanId := utils.CopyBytesToGo(args[0])
err := cm.api.EnableDirectMessages(marshalledChanId)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
return nil
}
// DisableDirectMessages removes the token for direct messaging for a
// given channel.
//
// Parameters:
// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array).
//
// Returns:
// - Throws a TypeError if saving the DM token fails
func (cm *ChannelsManager) DisableDirectMessages(_ js.Value, args []js.Value) any {
marshalledChanId := utils.CopyBytesToGo(args[0])
err := cm.api.DisableDirectMessages(marshalledChanId)
if err != nil {
utils.Throw(utils.TypeError, err)
return nil
}
return nil
}
////////////////////////////////////////////////////////////////////////////////
// Channel Share URL //
////////////////////////////////////////////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment