Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only let top admin purge. Fixes #2731 #2732

Merged
merged 2 commits into from
Feb 14, 2023
Merged

Only let top admin purge. Fixes #2731 #2732

merged 2 commits into from
Feb 14, 2023

Conversation

dessalines
Copy link
Member

No description provided.

let admins = PersonViewSafe::admins(pool).await?;
let top_admin = admins
.get(0)
.ok_or_else(|| LemmyError::from_message("no admins"))?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice way to convert a vector to an error if that index is missing. No idea why rust lets you get slices and them not be options / results, potentially throwing runtime errors.

@dessalines dessalines merged commit 9d7009c into main Feb 14, 2023
Nutomic pushed a commit that referenced this pull request Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants