Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for fetching the current user's connections (#1401)
This allows fetching of the current users connections to third party services, which are shown on the profile. This requires a user token - not a bot token - and the OAuth2 `connections` scope. Example output: ```rust [ Connection { id: "Dinnerbone#0000", name: "Dinnerbone#0000", kind: "battlenet", revoked: false, integrations: [], verified: true, friend_sync: true, show_activity: true, visibility: Everyone, }, Connection { id: "317625", name: "Dinnerbone", kind: "github", revoked: false, integrations: [], verified: true, friend_sync: false, show_activity: true, visibility: Everyone, } ], ```
- Loading branch information
1 parent
c21f052
commit 6a400f9
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! Models for user connections. | ||
|
||
use super::prelude::*; | ||
|
||
/// Information about a connection between the current user and a third party service. | ||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[non_exhaustive] | ||
pub struct Connection { | ||
/// The ID of the account on the other side of this connection. | ||
pub id: String, | ||
/// The username of the account on the other side of this connection. | ||
pub name: String, | ||
/// The service that this connection represents (e.g. twitch, youtube) | ||
#[serde(rename = "type")] | ||
pub kind: String, | ||
/// Whether this connection has been revoked and is no longer valid. | ||
#[serde(default)] | ||
pub revoked: bool, | ||
/// A list of partial guild [`Integration`]s that use this connection. | ||
#[serde(default)] | ||
pub integrations: Vec<Integration>, | ||
/// Whether this connection has been verified and the user has proven they own the account. | ||
pub verified: bool, | ||
/// Whether friend sync is enabled for this connection. | ||
pub friend_sync: bool, | ||
/// Whether activities related to this connection will be shown in presence updates. | ||
pub show_activity: bool, | ||
/// The visibility of this connection. | ||
pub visibility: ConnectionVisibility, | ||
} | ||
|
||
/// The visibility of a user connection on a user's profile. | ||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] | ||
#[non_exhaustive] | ||
#[repr(u8)] | ||
pub enum ConnectionVisibility { | ||
None = 0, | ||
Everyone = 1, | ||
Unknown = !0, | ||
} | ||
|
||
enum_number!(ConnectionVisibility { | ||
None, | ||
Everyone | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters