From 656e6dc4cefc911a20ef792439c1675251cb5b2c Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:19:28 +0100 Subject: [PATCH 1/2] add support for creating private channels --- addons/talo/apis/channels_api.gd | 7 ++++--- addons/talo/entities/channel.gd | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/talo/apis/channels_api.gd b/addons/talo/apis/channels_api.gd index a98382c..0f770e1 100644 --- a/addons/talo/apis/channels_api.gd +++ b/addons/talo/apis/channels_api.gd @@ -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 @@ -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: diff --git a/addons/talo/entities/channel.gd b/addons/talo/entities/channel.gd index 6a10542..5087d2c 100644 --- a/addons/talo/entities/channel.gd +++ b/addons/talo/entities/channel.gd @@ -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 @@ -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 From 89767aa34b368ffa573fda7240d21c8e5330d1e0 Mon Sep 17 00:00:00 2001 From: tudor <7089284+tudddorrr@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:31:48 +0100 Subject: [PATCH 2/2] channel invites api --- addons/talo/apis/channels_api.gd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/talo/apis/channels_api.gd b/addons/talo/apis/channels_api.gd index 0f770e1..fbd9010 100644 --- a/addons/talo/apis/channels_api.gd +++ b/addons/talo/apis/channels_api.gd @@ -158,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