add: block list stacks
This commit is contained in:
parent
9bb5f38f76
commit
b71ae1f5a4
28 changed files with 700 additions and 219 deletions
|
@ -76,6 +76,8 @@ pub enum AppScope {
|
|||
UserCreateCommunities,
|
||||
/// Create stacks on behalf of the user.
|
||||
UserCreateStacks,
|
||||
/// Create circles on behalf of the user.
|
||||
UserCreateCircles,
|
||||
/// Delete posts owned by the user.
|
||||
UserDeletePosts,
|
||||
/// Delete messages owned by the user.
|
||||
|
@ -106,6 +108,8 @@ pub enum AppScope {
|
|||
UserManageRequests,
|
||||
/// Manage the user's uploads.
|
||||
UserManageUploads,
|
||||
/// Manage the user's circles (add/remove users or delete).
|
||||
UserManageCircles,
|
||||
/// Edit posts created by the user.
|
||||
UserEditPosts,
|
||||
/// Edit drafts created by the user.
|
||||
|
@ -142,68 +146,6 @@ pub enum AppScope {
|
|||
CommunityManageChannels,
|
||||
}
|
||||
|
||||
impl AppScope {
|
||||
/// Parse the given input string as a list of scopes.
|
||||
pub fn parse(input: &str) -> Vec<AppScope> {
|
||||
let mut out: Vec<AppScope> = Vec::new();
|
||||
for scope in input.split(" ") {
|
||||
out.push(match scope {
|
||||
"user-read-profiles" => Self::UserReadProfiles,
|
||||
"user-read-profile" => Self::UserReadProfile,
|
||||
"user-read-settings" => Self::UserReadSettings,
|
||||
"user-read-sessions" => Self::UserReadSessions,
|
||||
"user-read-posts" => Self::UserReadPosts,
|
||||
"user-read-messages" => Self::UserReadMessages,
|
||||
"user-read-drafts" => Self::UserReadDrafts,
|
||||
"user-read-communities" => Self::UserReadCommunities,
|
||||
"user-read-sockets" => Self::UserReadSockets,
|
||||
"user-read-notifications" => Self::UserReadNotifications,
|
||||
"user-read-requests" => Self::UserReadRequests,
|
||||
"user-read-questions" => Self::UserReadQuestions,
|
||||
"user-create-posts" => Self::UserCreatePosts,
|
||||
"user-create-messages" => Self::UserCreateMessages,
|
||||
"user-create-questions" => Self::UserCreateQuestions,
|
||||
"user-create-ip-blocks" => Self::UserCreateIpBlock,
|
||||
"user-create-drafts" => Self::UserCreateDrafts,
|
||||
"user-create-communities" => Self::UserCreateCommunities,
|
||||
"user-delete-posts" => Self::UserDeletePosts,
|
||||
"user-delete-messages" => Self::UserDeleteMessages,
|
||||
"user-delete-questions" => Self::UserDeleteQuestions,
|
||||
"user-delete-drafts" => Self::UserDeleteDrafts,
|
||||
"user-manage-profile" => Self::UserManageProfile,
|
||||
"user-manage-stacks" => Self::UserManageStacks,
|
||||
"user-manage-relationships" => Self::UserManageRelationships,
|
||||
"user-manage-memberships" => Self::UserManageMemberships,
|
||||
"user-manage-following" => Self::UserManageFollowing,
|
||||
"user-manage-followers" => Self::UserManageFollowers,
|
||||
"user-manage-blocks" => Self::UserManageBlocks,
|
||||
"user-manage-notifications" => Self::UserManageNotifications,
|
||||
"user-manage-requests" => Self::UserManageRequests,
|
||||
"user-manage-uploads" => Self::UserManageUploads,
|
||||
"user-edit-posts" => Self::UserEditPosts,
|
||||
"user-edit-drafts" => Self::UserEditDrafts,
|
||||
"user-vote" => Self::UserVote,
|
||||
"user-react" => Self::UserReact,
|
||||
"user-join-communities" => Self::UserJoinCommunities,
|
||||
"mod-purge-posts" => Self::ModPurgePosts,
|
||||
"mod-delete-posts" => Self::ModDeletePosts,
|
||||
"mod-manage-warnings" => Self::ModManageWarnings,
|
||||
"user-read-emojis" => Self::UserReadEmojis,
|
||||
"community-create-emojis" => Self::CommunityCreateEmojis,
|
||||
"community-manage-emojis" => Self::CommunityManageEmojis,
|
||||
"community-delete" => Self::CommunityDelete,
|
||||
"community-manage" => Self::CommunityManage,
|
||||
"community-transfer-ownership" => Self::CommunityTransferOwnership,
|
||||
"community-read-memberships" => Self::CommunityReadMemberships,
|
||||
"community-create-channels" => Self::CommunityCreateChannels,
|
||||
"community-manage-channels" => Self::CommunityManageChannels,
|
||||
_ => continue,
|
||||
})
|
||||
}
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
impl AuthGrant {
|
||||
/// Check a verifier against the stored challenge (using the given [`PkceChallengeMethod`]).
|
||||
pub fn check_verifier(&self, verifier: &str) -> Result<()> {
|
||||
|
|
|
@ -23,6 +23,11 @@ pub enum StackMode {
|
|||
/// `users` vec contains ID of users to EXCLUDE from the timeline;
|
||||
/// every other user is included
|
||||
Exclude,
|
||||
/// `users` vec contains ID of users to show in a user listing on the stack's
|
||||
/// page (instead of a timeline).
|
||||
///
|
||||
/// Other users can block the entire list (creating a `StackBlock`, not a `UserBlock`).
|
||||
BlockList,
|
||||
}
|
||||
|
||||
impl Default for StackMode {
|
||||
|
@ -70,3 +75,23 @@ impl UserStack {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct StackBlock {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub initiator: usize,
|
||||
pub stack: usize,
|
||||
}
|
||||
|
||||
impl StackBlock {
|
||||
/// Create a new [`StackBlock`].
|
||||
pub fn new(initiator: usize, stack: usize) -> Self {
|
||||
Self {
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp(),
|
||||
initiator,
|
||||
stack,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue