aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-04 23:32:24 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-04 23:32:24 +0200
commit95e43ac88a322251a5e5a7d529b7b20a511978fd (patch)
tree52e86d7917b7de9c3c2e38fdd580a621c2726961 /common/src
parentae6885187b0aa881164151ab97bd4887c83b775a (diff)
downloadjellything-95e43ac88a322251a5e5a7d529b7b20a511978fd.tar
jellything-95e43ac88a322251a5e5a7d529b7b20a511978fd.tar.bz2
jellything-95e43ac88a322251a5e5a7d529b7b20a511978fd.tar.zst
more permissions
Diffstat (limited to 'common/src')
-rw-r--r--common/src/stream.rs2
-rw-r--r--common/src/user.rs21
2 files changed, 18 insertions, 5 deletions
diff --git a/common/src/stream.rs b/common/src/stream.rs
index 8a7ff36..6c93294 100644
--- a/common/src/stream.rs
+++ b/common/src/stream.rs
@@ -18,7 +18,7 @@ pub struct StreamSpec {
}
#[rustfmt::skip]
-#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "snake_case")]
#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))]
pub enum StreamFormat {
diff --git a/common/src/user.rs b/common/src/user.rs
index b049346..3c1c5b0 100644
--- a/common/src/user.rs
+++ b/common/src/user.rs
@@ -1,3 +1,4 @@
+use crate::{stream::StreamFormat, user};
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt::Display};
@@ -17,22 +18,26 @@ pub struct PermissionSet(pub HashMap<UserPermission, bool>);
#[serde(rename_all = "snake_case")]
pub enum UserPermission {
Admin,
- OriginalStream,
Transcode,
ManageUsers,
FederatedContent,
GenerateInvite,
+ StreamFormat(StreamFormat),
AccessNode(String),
}
impl UserPermission {
pub const ALL_ENUMERABLE: &'static [UserPermission] = {
use UserPermission::*;
- &[Admin, OriginalStream, Transcode]
+ &[Admin, Transcode, StreamFormat(user::StreamFormat::Original)]
};
pub fn default_value(&self) -> bool {
+ use user::StreamFormat::*;
use UserPermission::*;
- matches!(self, Transcode)
+ matches!(
+ self,
+ Transcode | StreamFormat(Jhls | HlsMaster | HlsVariant | Matroska | Segment)
+ )
}
}
@@ -41,7 +46,15 @@ impl Display for UserPermission {
f.write_str(&match self {
UserPermission::FederatedContent => format!("access to federated content"),
UserPermission::Admin => format!("administrative rights"),
- UserPermission::OriginalStream => format!("download of the original media"),
+ UserPermission::StreamFormat(StreamFormat::Original) => {
+ format!("downloading the original media")
+ }
+ UserPermission::StreamFormat(StreamFormat::Matroska) => {
+ format!("downloading a remuxed WebM/Matroska version of the media ")
+ }
+ UserPermission::StreamFormat(x) => {
+ format!("downloading media via {x:?}")
+ }
UserPermission::Transcode => format!("transcoding"),
UserPermission::ManageUsers => format!("management of all users"),
UserPermission::GenerateInvite => format!("inviting new users"),