From 5e131d065c8afeb1e8f52e6cb20d0bfabf658b17 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Wed, 15 Feb 2023 16:33:43 -0500 Subject: [PATCH 1/4] feat(model, cache): add `managed` field to `Channel` --- twilight-cache-inmemory/src/event/guild.rs | 2 ++ twilight-cache-inmemory/src/permission.rs | 2 ++ twilight-cache-inmemory/src/test.rs | 1 + twilight-model/src/channel/mod.rs | 12 ++++++++++++ twilight-model/src/guild/template/mod.rs | 4 ++++ 5 files changed, 21 insertions(+) diff --git a/twilight-cache-inmemory/src/event/guild.rs b/twilight-cache-inmemory/src/event/guild.rs index 9d5503f67e8..7a580eda6c3 100644 --- a/twilight-cache-inmemory/src/event/guild.rs +++ b/twilight-cache-inmemory/src/event/guild.rs @@ -323,6 +323,7 @@ mod tests { kind: ChannelType::GuildText, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -360,6 +361,7 @@ mod tests { kind: ChannelType::PublicThread, last_message_id: None, last_pin_timestamp: None, + managed: Some(true), member: Some(ThreadMember { flags: 0, id: Some(Id::new(1)), diff --git a/twilight-cache-inmemory/src/permission.rs b/twilight-cache-inmemory/src/permission.rs index 008053f8338..577c7141b71 100644 --- a/twilight-cache-inmemory/src/permission.rs +++ b/twilight-cache-inmemory/src/permission.rs @@ -786,6 +786,7 @@ mod tests { kind: ChannelType::GuildText, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -838,6 +839,7 @@ mod tests { kind: ChannelType::PublicThread, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, diff --git a/twilight-cache-inmemory/src/test.rs b/twilight-cache-inmemory/src/test.rs index 15715a7a50d..1b1935c03aa 100644 --- a/twilight-cache-inmemory/src/test.rs +++ b/twilight-cache-inmemory/src/test.rs @@ -246,6 +246,7 @@ pub fn guild_channel_text() -> (Id, Id, Channel) { kind: ChannelType::GuildText, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, diff --git a/twilight-model/src/channel/mod.rs b/twilight-model/src/channel/mod.rs index 9ed666eb023..29b3746559b 100644 --- a/twilight-model/src/channel/mod.rs +++ b/twilight-model/src/channel/mod.rs @@ -111,6 +111,9 @@ pub struct Channel { /// ID of the last message pinned in the channel. #[serde(skip_serializing_if = "Option::is_none")] pub last_pin_timestamp: Option, + /// For group DM channels: whether the channel is managed by an application via the `gdm.join` OAuth2 scope. + #[serde(skip_serializing_if = "Option::is_none")] + pub managed: Option, /// Member that created the channel. #[serde(skip_serializing_if = "Option::is_none")] pub member: Option, @@ -236,6 +239,7 @@ mod tests { kind: ChannelType::GuildText, last_message_id: Some(Id::new(3)), last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -278,6 +282,7 @@ mod tests { kind: ChannelType::GuildCategory, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -332,6 +337,7 @@ mod tests { kind: ChannelType::GuildAnnouncement, last_message_id: Some(Id::new(4)), last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -393,6 +399,7 @@ mod tests { kind: ChannelType::AnnouncementThread, last_message_id: Some(Id::new(3)), last_pin_timestamp: None, + managed: Some(true), member: Some(ThreadMember { flags: 0_u64, id: Some(Id::new(4)), @@ -440,6 +447,7 @@ mod tests { "user_id": "5", }, "default_auto_archive_duration": 60, + "managed": true, "member_count": 50, "message_count": 50, "name": "newsthread", @@ -481,6 +489,7 @@ mod tests { kind: ChannelType::PublicThread, last_message_id: Some(Id::new(3)), last_pin_timestamp: None, + managed: Some(true), member: Some(ThreadMember { flags: 0_u64, id: Some(Id::new(4)), @@ -528,6 +537,7 @@ mod tests { "user_id": "5", }, "default_auto_archive_duration": 60, + "managed": true, "member_count": 50, "message_count": 50, "name": "publicthread", @@ -570,6 +580,7 @@ mod tests { kind: ChannelType::PrivateThread, last_message_id: Some(Id::new(3)), last_pin_timestamp: None, + managed: Some(true), member: Some(ThreadMember { flags: 0_u64, id: Some(Id::new(4)), @@ -625,6 +636,7 @@ mod tests { }, "default_auto_archive_duration": 60, "invitable": true, + "managed": true, "member_count": -1, "message_count": 50, "name": "privatethread", diff --git a/twilight-model/src/guild/template/mod.rs b/twilight-model/src/guild/template/mod.rs index d0b2e6bfada..6cca6b1b276 100644 --- a/twilight-model/src/guild/template/mod.rs +++ b/twilight-model/src/guild/template/mod.rs @@ -221,6 +221,7 @@ mod tests { kind: ChannelType::GuildCategory, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -257,6 +258,7 @@ mod tests { kind: ChannelType::GuildText, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -306,6 +308,7 @@ mod tests { kind: ChannelType::GuildCategory, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, @@ -342,6 +345,7 @@ mod tests { kind: ChannelType::GuildVoice, last_message_id: None, last_pin_timestamp: None, + managed: None, member: None, member_count: None, message_count: None, From cf4059f33fa21819eb2302e86694c70a76ddde34 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Thu, 16 Feb 2023 09:38:21 -0500 Subject: [PATCH 2/4] Update twilight-model/src/channel/mod.rs Co-authored-by: Zeyla --- twilight-model/src/channel/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/twilight-model/src/channel/mod.rs b/twilight-model/src/channel/mod.rs index 29b3746559b..e48f71b11c7 100644 --- a/twilight-model/src/channel/mod.rs +++ b/twilight-model/src/channel/mod.rs @@ -111,7 +111,13 @@ pub struct Channel { /// ID of the last message pinned in the channel. #[serde(skip_serializing_if = "Option::is_none")] pub last_pin_timestamp: Option, - /// For group DM channels: whether the channel is managed by an application via the `gdm.join` OAuth2 scope. + /// Whether the channel is managed by an application via the [`GDM_JOIN`] + /// scope. + /// + /// This is only applicable to [group channels]. + /// + /// [`GDM_JOIN`]: crate::scope::GDM_JOIN + /// [group channels]: ChannelType::Group #[serde(skip_serializing_if = "Option::is_none")] pub managed: Option, /// Member that created the channel. From b16caf46f8d3f959ca901b19c41233c27a4ffd7b Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Thu, 16 Feb 2023 09:50:00 -0500 Subject: [PATCH 3/4] fix: invalid doc link --- twilight-model/src/channel/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twilight-model/src/channel/mod.rs b/twilight-model/src/channel/mod.rs index e48f71b11c7..2138a620141 100644 --- a/twilight-model/src/channel/mod.rs +++ b/twilight-model/src/channel/mod.rs @@ -111,12 +111,12 @@ pub struct Channel { /// ID of the last message pinned in the channel. #[serde(skip_serializing_if = "Option::is_none")] pub last_pin_timestamp: Option, - /// Whether the channel is managed by an application via the [`GDM_JOIN`] - /// scope. + /// Whether the channel is managed by an application via the [`gdm.join`] + /// oauth scope. /// /// This is only applicable to [group channels]. /// - /// [`GDM_JOIN`]: crate::scope::GDM_JOIN + /// [`gdm.join`]: https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes /// [group channels]: ChannelType::Group #[serde(skip_serializing_if = "Option::is_none")] pub managed: Option, From 15404f47570b5c995d43d024670eeaa096821a06 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer Date: Thu, 16 Feb 2023 20:16:07 -0800 Subject: [PATCH 4/4] intradoc link --- twilight-model/src/channel/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twilight-model/src/channel/mod.rs b/twilight-model/src/channel/mod.rs index 2138a620141..208a757fd34 100644 --- a/twilight-model/src/channel/mod.rs +++ b/twilight-model/src/channel/mod.rs @@ -116,7 +116,7 @@ pub struct Channel { /// /// This is only applicable to [group channels]. /// - /// [`gdm.join`]: https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes + /// [`gdm.join`]: crate::oauth::scope::GDM_JOIN /// [group channels]: ChannelType::Group #[serde(skip_serializing_if = "Option::is_none")] pub managed: Option,