8000 Private channels + invites by tudddorrr · Pull Request #103 · TaloDev/godot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Private channels + invites #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions addons/talo/apis/channels_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func get_subscribed_channels() -> Array[TaloChannel]:
_:
return []

## Create a new channel. The player who creates this channel will automatically become the owner. If auto cleanup is enabled, the channel will be deleted when the owner or the last member leaves.
func create(name: String, auto_cleanup: bool = false, props: Dictionary = {}) -> TaloChannel:
## Create a new channel. The player who creates this channel will automatically become the owner. If auto cleanup is enabled, the channel will be deleted when the owner or the last member leaves. Private channels can only be joined by players who have been invited to the channel.
func create(name: String, auto_cleanup: bool = false, props: Dictionary = {}, private: bool = false) -> TaloChannel:
if Talo.identity_check() != OK:
return

Expand All @@ -81,7 +81,8 @@ func create(name: String, auto_cleanup: bool = false, props: Dictionary = {}) ->
var res := await client.make_request(HTTPClient.METHOD_POST, "", {
name = name,
autoCleanup = auto_cleanup,
props = props_to_send
props = props_to_send,
private = private
})

match res.status:
Expand Down Expand Up @@ -157,6 +158,19 @@ func send_message(channel_id: int, message: String) -> void:
message = message
})

## Invite a player to a channel. The invitee will automatically join the channel. This will only work if the current player is the owner of the channel.
func invite(channel_id: int, player_alias_id: int) -> void:
if Talo.identity_check() != OK:
return

var res = await client.make_request(HTTPClient.METHOD_POST, "/%s/invite" % channel_id, {
inviteeAliasId = player_alias_id
})

match res.status:
403:
push_error("Player does not have permissions to invite players to channel %s." % channel_id)

class ChannelPage:
var channels: Array[TaloChannel]
var count: int
Expand Down
2 changes: 2 additions & 0 deletions addons/talo/entities/channel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var name: String
var owner_alias: TaloPlayerAlias
var total_messages: int
var member_count: int
var private: bool
var created_at: String
var updated_at: String

Expand All @@ -17,5 +18,6 @@ func _init(data: Dictionary):
owner_alias = TaloPlayerAlias.new(data.owner)
total_messages = data.totalMessages
member_count = data.get('memberCount', 0) # TODO: socket messages don't currently send the memberCount
private = data.private
created_at = data.createdAt
updated_at = data.updatedAt
0