Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
8967dbf8
Commit
8967dbf8
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix share URL
parent
897cfe3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!510
Release
,
!423
Fix share URL
,
!340
Project/channels
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/channels.go
+68
-34
68 additions, 34 deletions
bindings/channels.go
with
68 additions
and
34 deletions
bindings/channels.go
+
68
−
34
View file @
8967dbf8
...
@@ -454,6 +454,74 @@ func makeChannelPrivateKeyStoreKey(channelID *id.ID) string {
...
@@ -454,6 +454,74 @@ func makeChannelPrivateKeyStoreKey(channelID *id.ID) string {
return
channelPrivateKeyStoreKey
+
"/"
+
channelID
.
String
()
return
channelPrivateKeyStoreKey
+
"/"
+
channelID
.
String
()
}
}
// DecodePublicURL decodes the channel URL into a channel pretty print. This
// function can only be used for public channel URLs. To get the privacy level
// of a channel URL, use [GetShareUrlType].
//
// Parameters:
// - url - The channel's share URL. Should be received from another user or
// generated via [GetShareURL].
//
// Returns:
// - string - The channel pretty print.
func
DecodePublicURL
(
url
string
)
(
string
,
error
)
{
c
,
err
:=
cryptoBroadcast
.
DecodeShareURL
(
url
,
""
)
if
err
!=
nil
{
return
""
,
err
}
return
c
.
PrettyPrint
(),
nil
}
// DecodePrivateURL decodes the channel URL, using the password, into a channel
// pretty print. This function can only be used for private or secret channel
// URLs. To get the privacy level of a channel URL, use [GetShareUrlType].
//
// Parameters:
// - url - The channel's share URL. Should be received from another user or
// generated via [GetShareURL].
// - password - The password needed to decrypt the secret data in the URL.
//
// Returns:
// - The channel pretty print.
func
DecodePrivateURL
(
url
,
password
string
)
(
string
,
error
)
{
c
,
err
:=
cryptoBroadcast
.
DecodeShareURL
(
url
,
password
)
if
err
!=
nil
{
return
""
,
err
}
return
c
.
PrettyPrint
(),
nil
}
// GetChannelJSON returns the JSON of the channel for the given pretty print.
//
// Parameters:
// - prettyPrint - The pretty print of the channel.
//
// Returns:
// - JSON of the [broadcast.Channel] object.
//
// Example JSON of [broadcast.Channel]:
// {
// "ReceptionID": "Ja/+Jh+1IXZYUOn+IzE3Fw/VqHOscomD0Q35p4Ai//kD",
// "Name": "My_Channel",
// "Description": "Here is information about my channel.",
// "Salt": "+tlrU/htO6rrV3UFDfpQALUiuelFZ+Cw9eZCwqRHk+g=",
// "RsaPubKeyHash": "PViT1mYkGBj6AYmE803O2RpA7BX24EjgBdldu3pIm4o=",
// "RsaPubKeyLength": 5,
// "RSASubPayloads": 1,
// "Secret": "JxZt/wPx2luoPdHY6jwbXqNlKnixVU/oa9DgypZOuyI=",
// "Level": 0
// }
func
GetChannelJSON
(
prettyPrint
string
)
([]
byte
,
error
)
{
c
,
err
:=
cryptoBroadcast
.
NewChannelFromPrettyPrint
(
prettyPrint
)
if
err
!=
nil
{
return
nil
,
nil
}
return
json
.
Marshal
(
c
)
}
// ChannelInfo contains information about a channel.
// ChannelInfo contains information about a channel.
//
//
// Example of ChannelInfo JSON:
// Example of ChannelInfo JSON:
...
@@ -524,40 +592,6 @@ func (cm *ChannelsManager) JoinChannel(channelPretty string) ([]byte, error) {
...
@@ -524,40 +592,6 @@ func (cm *ChannelsManager) JoinChannel(channelPretty string) ([]byte, error) {
return
info
,
err
return
info
,
err
}
}
// JoinChannelFromURL joins the given channel from a URL. It will fail if the
// channel has already been joined. A password is required unless it is of the
// privacy level [broadcast.Public], in which case it can be left empty. To get
// the privacy level of a channel URL, use [GetShareUrlType].
//
// Parameters:
// - url - The channel's share URL. Should be received from another user or
// generated via [GetShareURL].
// - password - The password needed to decrypt the secret data in the URL. Only
// required for private or secret channels.
//
// Returns:
// - []byte - [ChannelInfo] describes all relevant channel info.
func
(
cm
*
ChannelsManager
)
JoinChannelFromURL
(
url
,
password
string
)
([]
byte
,
error
)
{
c
,
err
:=
cryptoBroadcast
.
DecodeShareURL
(
url
,
password
)
if
err
!=
nil
{
return
nil
,
err
}
info
,
err
:=
json
.
Marshal
(
&
ChannelInfo
{
Name
:
c
.
Name
,
Description
:
c
.
Description
,
ChannelID
:
c
.
ReceptionID
.
String
(),
})
if
err
!=
nil
{
return
nil
,
err
}
// Join the channel using the API
err
=
cm
.
api
.
JoinChannel
(
c
)
return
info
,
err
}
// GetChannels returns the IDs of all channels that have been joined.
// GetChannels returns the IDs of all channels that have been joined.
//
//
// Returns:
// Returns:
...
...
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