Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
61542340
Commit
61542340
authored
Apr 25, 2023
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Add dm.SendInvite bindings
parent
3a13df27
No related branches found
No related tags found
2 merge requests
!109
Project/haven beta
,
!100
Xx 4601/haven invites
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
wasm/dm.go
+51
-1
51 additions, 1 deletion
wasm/dm.go
with
51 additions
and
1 deletion
wasm/dm.go
+
51
−
1
View file @
61542340
...
@@ -57,6 +57,7 @@ func newDMClientJS(api *bindings.DMClient) map[string]any {
...
@@ -57,6 +57,7 @@ func newDMClientJS(api *bindings.DMClient) map[string]any {
"SendText"
:
js
.
FuncOf
(
cm
.
SendText
),
"SendText"
:
js
.
FuncOf
(
cm
.
SendText
),
"SendReply"
:
js
.
FuncOf
(
cm
.
SendReply
),
"SendReply"
:
js
.
FuncOf
(
cm
.
SendReply
),
"SendReaction"
:
js
.
FuncOf
(
cm
.
SendReaction
),
"SendReaction"
:
js
.
FuncOf
(
cm
.
SendReaction
),
"SendInvite"
:
js
.
FuncOf
(
cm
.
SendInvite
),
"Send"
:
js
.
FuncOf
(
cm
.
Send
),
"Send"
:
js
.
FuncOf
(
cm
.
Send
),
}
}
...
@@ -429,7 +430,8 @@ func (dmc *DMClient) SendReply(_ js.Value, args []js.Value) any {
...
@@ -429,7 +430,8 @@ func (dmc *DMClient) SendReply(_ js.Value, args []js.Value) any {
// Users will drop the reaction if they do not recognize the reactTo message.
// Users will drop the reaction if they do not recognize the reactTo message.
//
//
// Parameters:
// Parameters:
// - args[0] - Marshalled bytes of the channel [id.ID] (Uint8Array).
// - args[0] - The bytes of the public key of the partner's ED25519 signing
// key (Uint8Array).
// - args[1] - The token used to derive the reception ID for the partner (int).
// - args[1] - The token used to derive the reception ID for the partner (int).
// - args[2] - The user's reaction. This should be a single emoji with no
// - args[2] - The user's reaction. This should be a single emoji with no
// other characters. As such, a Unicode string is expected (string).
// other characters. As such, a Unicode string is expected (string).
...
@@ -470,6 +472,54 @@ func (dmc *DMClient) SendReaction(_ js.Value, args []js.Value) any {
...
@@ -470,6 +472,54 @@ func (dmc *DMClient) SendReaction(_ js.Value, args []js.Value) any {
return
utils
.
CreatePromise
(
promiseFn
)
return
utils
.
CreatePromise
(
promiseFn
)
}
}
// SendInvite is used to send to a DM partner an invitation to another
// channel.
//
// If the channel ID for the invitee channel is not recognized by the Manager,
// then an error will be returned.
//
// Parameters:
// - args[0] - The ID of [ChannelsManager] object in tracker. This can be
// retrieved using [ChannelsManager.GetID].
// - args[1] - The bytes of the public key of the partner's ED25519 signing
// key (Uint8Array).
// - args[2] - The token used to derive the reception ID for the partner (int).
// - args[3] - Marshalled bytes of the channel the user is inviting another
// user to.
// - args[4] - The contents of the message. The message should be at most 510
// bytes. This is expected to be Unicode, and thus a string data type is
// expected.
// - args[5] - The URL to append the channel info to.
// - args[6] - The maximum number of uses the link can be used (0 for
// unlimited).
// - args[7] - A JSON marshalled [xxdk.CMIXParams]. This may be empty,
// and GetDefaultCMixParams will be used internally.
func
(
dmc
*
DMClient
)
SendInvite
(
_
js
.
Value
,
args
[]
js
.
Value
)
any
{
var
(
channelManagerId
=
args
[
0
]
.
Int
()
partnerPubKeyBytes
=
utils
.
CopyBytesToGo
(
args
[
1
])
partnerToken
=
int32
(
args
[
2
]
.
Int
())
marshalledInviteToId
=
utils
.
CopyBytesToGo
(
args
[
3
])
msg
=
args
[
4
]
.
String
()
host
=
args
[
5
]
.
String
()
maxUses
=
args
[
6
]
.
Int
()
cmixParamsJSON
=
utils
.
CopyBytesToGo
(
args
[
7
])
)
promiseFn
:=
func
(
resolve
,
reject
func
(
args
...
any
)
js
.
Value
)
{
sendReport
,
err
:=
dmc
.
api
.
SendInvite
(
channelManagerId
,
partnerPubKeyBytes
,
partnerToken
,
marshalledInviteToId
,
msg
,
host
,
maxUses
,
cmixParamsJSON
)
if
err
!=
nil
{
reject
(
utils
.
JsTrace
(
err
))
}
else
{
resolve
(
utils
.
CopyBytesToJS
(
sendReport
))
}
}
return
utils
.
CreatePromise
(
promiseFn
)
}
// Send is used to send a raw message. In general, it
// Send is used to send a raw message. In general, it
// should be wrapped in a function that defines the wire protocol.
// should be wrapped in a function that defines the wire protocol.
//
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment