feat(!1246): Config defined admin list #1253

Merged
Jade merged 3 commits from Terryiscool160/continuwuity:terry/admin-config into main 2025-12-31 19:43:12 +00:00
Contributor

i have done testing to ensure that both the .well-known support endpoint & admin commands work with the new configuration values. however, i have not yet ensured that users joining the admin room after startup are marked as admins without requiring a restart

Closes: #1246

Pull request checklist:

  • This pull request targets the main branch, and the branch is named something other than
    main.
  • I have written an appropriate pull request title and my description is clear.
  • I understand I am responsible for the contents of this pull request.
  • I have followed the contributing guidelines:
i have done testing to ensure that both the .well-known support endpoint & admin commands work with the new configuration values. however, i have not yet ensured that users joining the admin room after startup are marked as admins without requiring a restart Closes: #1246 **Pull request checklist:** - [x] This pull request targets the `main` branch, and the branch is named something other than `main`. - [x] I have written an appropriate pull request title and my description is clear. - [x] I understand I am responsible for the contents of this pull request. - I have followed the [contributing guidelines][c1]: - [x] My contribution follows the [code style][c2], if applicable. - [x] I ran [pre-commit checks][c1pc] before opening/drafting this pull request. - [ ] I have [tested my contribution][c1t] (or proof-read it for documentation-only changes) myself, if applicable. This includes ensuring code compiles. - [x] My commit messages follow the [commit message format][c1cm] and are descriptive. - [x] I have written a [news fragment][n1] for this PR, if applicable [c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md [c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx [c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks [c1t]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#running-tests-locally [c1cm]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#commit-messages [n1]: https://towncrier.readthedocs.io/en/stable/tutorial.html#creating-news-fragments
feat: Config defined admin list
Some checks are pending
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
Update flake hashes / update-flake-hashes (pull_request) Blocked by required conditions
b9686a162d
docs: Changelog
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
Update flake hashes / update-flake-hashes (pull_request) Has been cancelled
5f08680cb9
Terryiscool160 force-pushed terry/admin-config from 5f08680cb9
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
Update flake hashes / update-flake-hashes (pull_request) Has been cancelled
to b9d338f8eb
Some checks are pending
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
2025-12-30 23:17:23 +00:00
Compare
nex added this to the 0.5.2 milestone 2025-12-30 23:27:23 +00:00
@ -86,3 +75,1 @@
matrix_id: Some(user_id.to_owned()),
});
}
for user_id in admin_users.iter() {
Owner

The admin bot ought to count as an admin pretty much everywhere but here, because it can be logged into using the emergency password

The admin bot ought to count as an admin pretty much everywhere but here, because it can be logged into using the emergency password
Terryiscool160 marked this conversation as resolved
@ -22,0 +23,4 @@
// that status independently of their presence admin room if not
if !self.user_is_admin(user_id).await {
let mut admin_list = self.admin_list.write().await;
admin_list.insert(user_id.to_owned());
Owner

this might kind of give a false sense of security, given it gets wiped on restart

this might kind of give a false sense of security, given it gets wiped on restart
Author
Contributor

just wondering - should i basically just make a warning alerting the user that it isnt persistent if they're added here?

just wondering - should i basically just make a warning alerting the user that it isnt persistent if they're added here?
Owner

If joining them to the room fails, is the issue - this will make them admin for a bit but not persistently

If joining them to the room fails, is the issue - this will make them admin for a bit but not persistently
Owner

basically what should happen is it shouldn't try add to the admin list at first here. If it succeds, they're ad amin already successfully. If it fails, then they're not an admin

basically what should happen is it shouldn't try add to the admin list at first here. If it succeds, they're ad amin already successfully. If it fails, then they're not an admin
Owner

If you really want to make sure it succeeds anyway, you can add a thing that happends if it fails to join the admin room that adds it to the config list and warns that the user may no longer be admin if the config is reloaded or the server restarts

If you really want to make sure it succeeds anyway, you can add a thing that happends if it fails to join the admin room that adds it to the config list and warns that the user may no longer be admin if the config is reloaded or the server restarts
Jade marked this conversation as resolved
@ -177,2 +184,4 @@
use MembershipState::{Invite, Join, Knock, Leave};
if self.user_is_admin(user_id).await {
let mut admin_list = self.admin_list.write().await;
Owner

same here - it should warn if the user is in the config admin list

same here - it should warn if the user is in the config admin list
Jade marked this conversation as resolved
@ -115,6 +118,7 @@ impl crate::Service for Service {
let mut signals = self.services.server.signal.subscribe();
let receiver = self.channel.1.clone();
self.setup_admins().await;
Owner

this needs to be called on reload if you're doing it this way i think.

this needs to be called on reload if you're doing it this way i think.
Jade marked this conversation as resolved
fix: Changes based on comments
Some checks are pending
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
6acee3e49e
@ -352,0 +356,4 @@
/// Creates the list of admins for this server. First loads
/// the admin_list from the configuration, then adds users from
/// the admin room if applicable.
pub async fn setup_admins(&self) {
Owner

Rather than writing to the state, only to have it overwritten, this should be calculate_admins, return the list of admins and then be called directly by the two functions below it. Alternatively merge it with the get admins function, because it might be doing the exact same thing.

Rather than writing to the state, only to have it overwritten, this should be calculate_admins, return the list of admins and then be called directly by the two functions below it. Alternatively merge it with the get admins function, because it might be doing the exact same thing.
Jade marked this conversation as resolved
fix: Repair compilation, remove log & merge functions
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 2m1s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 22m18s
ad46df0531
@ -179,0 +186,4 @@
.contains(&user_id.to_owned())
{
warn!(
"Revoking the admin status of {user_id} will not be persistent as they are within \
Owner

will not work* with the most recent change haha

will not work* with the most recent change haha
Jade marked this conversation as resolved
Jade approved these changes 2025-12-31 02:29:52 +00:00
Jade left a comment
Owner

Yay! will merge tommorow with that last message fixed. Thank you!

Yay! will merge tommorow with that last message fixed. Thank you!
Jade changed title from WIP: feat(!1246): Config defined admin list to feat(!1246): Config defined admin list 2025-12-31 19:32:29 +00:00
Jade force-pushed terry/admin-config from ad46df0531
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 2m1s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 22m18s
to 442f887c98
Some checks failed
Documentation / Build and Deploy Documentation (push) Waiting to run
Checks / Prek / Pre-commit & Formatting (push) Waiting to run
Checks / Prek / Clippy and Cargo Tests (push) Waiting to run
Release Docker Image / Build linux-amd64 (release) (push) Waiting to run
Release Docker Image / Build linux-arm64 (release) (push) Waiting to run
Release Docker Image / Create Multi-arch Release Manifest (push) Blocked by required conditions
Release Docker Image / Build linux-amd64 (max-perf) (push) Blocked by required conditions
Release Docker Image / Build linux-arm64 (max-perf) (push) Blocked by required conditions
Release Docker Image / Create Max-Perf Manifest (push) Blocked by required conditions
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Failing after 1m35s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 24m33s
2025-12-31 19:42:08 +00:00
Compare
Jade merged commit 442f887c98 into main 2025-12-31 19:43:12 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
continuwuation/continuwuity!1253
No description provided.