add: profile connections, spotify connection
This commit is contained in:
parent
a5c2356940
commit
33ba576d4a
31 changed files with 931 additions and 19 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use super::permissions::FinePermission;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use totp_rs::TOTP;
|
||||
|
@ -35,8 +37,14 @@ pub struct User {
|
|||
pub post_count: usize,
|
||||
#[serde(default)]
|
||||
pub request_count: usize,
|
||||
/// External service connection details.
|
||||
#[serde(default)]
|
||||
pub connections: UserConnections,
|
||||
}
|
||||
|
||||
pub type UserConnections =
|
||||
HashMap<ConnectionService, (ExternalConnectionInfo, ExternalConnectionData)>;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum ThemePreference {
|
||||
Auto,
|
||||
|
@ -220,6 +228,7 @@ impl User {
|
|||
recovery_codes: Vec::new(),
|
||||
post_count: 0,
|
||||
request_count: 0,
|
||||
connections: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,6 +342,42 @@ impl User {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum ConnectionService {
|
||||
/// A connection to a Spotify account.
|
||||
Spotify,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum ConnectionType {
|
||||
/// A connection through a token with an expiration time.
|
||||
Token,
|
||||
/// <https://www.rfc-editor.org/rfc/rfc7636>
|
||||
PKCE,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ExternalConnectionInfo {
|
||||
pub con_type: ConnectionType,
|
||||
pub data: HashMap<String, String>,
|
||||
pub show_on_profile: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ExternalConnectionData {
|
||||
pub external_urls: HashMap<String, String>,
|
||||
pub data: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl Default for ExternalConnectionData {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
external_urls: HashMap::new(),
|
||||
data: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Notification {
|
||||
pub id: usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue