Files
AstralRinth/src/models/teams.rs
Geometrically 16db28060c Project Types, Code Cleanup, and Rename Mods -> Projects (#192)
* Initial work for modpacks and project types

* Code cleanup, fix some issues

* Username route getting, remove pointless tests

* Base validator types + fixes

* Fix strange IML generation

* Multiple hash requests for version files

* Fix docker build (hopefully)

* Legacy routes

* Finish validator architecture

* Update rust version in dockerfile

* Added caching and fixed typo (#203)

* Added caching and fixed typo

* Fixed clippy error

* Removed log for cache

* Add final validators, fix how loaders are handled and add icons to tags

* Fix search module

* Fix parts of legacy API not working

Co-authored-by: Redblueflame <contact@redblueflame.com>
2021-05-30 15:02:07 -07:00

59 lines
1.6 KiB
Rust

use super::ids::Base62Id;
use crate::models::users::UserId;
use serde::{Deserialize, Serialize};
/// The ID of a team
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(from = "Base62Id")]
#[serde(into = "Base62Id")]
pub struct TeamId(pub u64);
pub const OWNER_ROLE: &str = "Owner";
// TODO: permissions, role names, etc
/// A team of users who control a project
#[derive(Serialize, Deserialize)]
pub struct Team {
/// The id of the team
pub id: TeamId,
/// A list of the members of the team
pub members: Vec<TeamMember>,
}
bitflags::bitflags! {
#[derive(Serialize, Deserialize)]
#[serde(transparent)]
pub struct Permissions: u64 {
const UPLOAD_VERSION = 1 << 0;
const DELETE_VERSION = 1 << 1;
const EDIT_DETAILS = 1 << 2;
const EDIT_BODY = 1 << 3;
const MANAGE_INVITES = 1 << 4;
const REMOVE_MEMBER = 1 << 5;
const EDIT_MEMBER = 1 << 6;
const DELETE_PROJECT = 1 << 7;
const ALL = 0b11111111;
}
}
impl Default for Permissions {
fn default() -> Permissions {
Permissions::UPLOAD_VERSION | Permissions::DELETE_VERSION
}
}
/// A member of a team
#[derive(Serialize, Deserialize, Clone)]
pub struct TeamMember {
/// The ID of the team this team member is a member of
pub team_id: TeamId,
/// The ID of the user associated with the member
pub user_id: UserId,
/// The role of the user in the team
pub role: String,
/// A bitset containing the user's permissions in this team
pub permissions: Option<Permissions>,
/// Whether the user has joined the team or is just invited to it
pub accepted: bool,
}