add: implement 9 new scopes, 21 new api endpoints
This commit is contained in:
parent
c3139ef1d2
commit
8f16068a34
14 changed files with 973 additions and 35 deletions
|
@ -387,6 +387,22 @@ impl User {
|
|||
)
|
||||
.ok()
|
||||
}
|
||||
|
||||
/// Clean the struct for public viewing.
|
||||
pub fn clean(&mut self) {
|
||||
self.password = String::new();
|
||||
self.salt = String::new();
|
||||
|
||||
self.tokens = Vec::new();
|
||||
self.grants = Vec::new();
|
||||
|
||||
self.recovery_codes = Vec::new();
|
||||
self.totp = String::new();
|
||||
|
||||
self.settings = UserSettings::default();
|
||||
self.stripe_id = String::new();
|
||||
self.connections = HashMap::new();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
@ -446,7 +462,7 @@ impl Notification {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct UserFollow {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
|
|
|
@ -36,6 +36,8 @@ pub enum PkceChallengeMethod {
|
|||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum AppScope {
|
||||
/// Read the profile of other user's on behalf of the user.
|
||||
UserReadProfiles,
|
||||
/// Read the user's profile (username, bio, etc).
|
||||
UserReadProfile,
|
||||
/// Read the user's settings.
|
||||
|
@ -52,6 +54,10 @@ pub enum AppScope {
|
|||
UserReadCommunities,
|
||||
/// Connect to sockets on the user's behalf.
|
||||
UserReadSockets,
|
||||
/// Read the user's notifications.
|
||||
UserReadNotifications,
|
||||
/// Read the user's requests.
|
||||
UserReadRequests,
|
||||
/// Create posts as the user.
|
||||
UserCreatePosts,
|
||||
/// Create messages as the user.
|
||||
|
@ -82,6 +88,16 @@ pub enum AppScope {
|
|||
///
|
||||
/// Also includes managing the membership of users in the user's communities.
|
||||
UserManageMemberships,
|
||||
/// Follow/unfollow users on behalf of the user.
|
||||
UserManageFollowing,
|
||||
/// Accept follow requests on behalf of the user.
|
||||
UserManageFollowers,
|
||||
/// Block/unblock users on behalf of the user.
|
||||
UserManageBlocks,
|
||||
/// Manage the user's notifications.
|
||||
UserManageNotifications,
|
||||
/// Manage the user's requests.
|
||||
UserManageRequests,
|
||||
/// Edit posts created by the user.
|
||||
UserEditPosts,
|
||||
/// Edit drafts created by the user.
|
||||
|
@ -94,6 +110,8 @@ pub enum AppScope {
|
|||
ModPurgePosts,
|
||||
/// Restore deleted posts.
|
||||
ModDeletePosts,
|
||||
/// Manage user warnings.
|
||||
ModManageWarnings,
|
||||
/// Get a list of all emojis available to the user.
|
||||
UserReadEmojis,
|
||||
/// Create emojis on behalf of the user.
|
||||
|
@ -116,6 +134,7 @@ impl 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,
|
||||
|
@ -124,6 +143,8 @@ impl AppScope {
|
|||
"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-create-posts" => Self::UserCreatePosts,
|
||||
"user-create-messages" => Self::UserCreateMessages,
|
||||
"user-create-questions" => Self::UserCreateQuestions,
|
||||
|
@ -138,12 +159,18 @@ impl AppScope {
|
|||
"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-edit-posts" => Self::UserEditPosts,
|
||||
"user-edit-drafts" => Self::UserEditDrafts,
|
||||
"user-vote" => Self::UserVote,
|
||||
"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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue