feat: adds base mod suport, including jot mod activity command #125

Merged
treadful merged 19 commits from feat/mod into main 2026-06-24 03:57:48 +00:00
Owner

Adds mod support.

Ref #112

Adds mod support. Ref #112
feat: adds base mod suport, including jot mod activity command
Some checks failed
/ test-and-check (pull_request) Failing after 18m48s
8ad9a2ab4f
fix(test): Fixes a test due to struct change
Some checks failed
/ test-and-check (pull_request) Has been cancelled
74b9e1cd56
feat(devops): adds cargo check for mod feature
Some checks failed
/ test-and-check (pull_request) Failing after 18m51s
c973c8ed1c
fix(test): broken from ADL refactor
All checks were successful
/ test-and-check (pull_request) Successful in 19m35s
9063c19b11
refactor: refactors slip auth to be reusable and simpler in the handlers
All checks were successful
/ test-and-check (pull_request) Successful in 18m19s
8a7f2af145
@ -738,0 +803,4 @@
signature: &str,
) -> Result<AuditLog, JotApiError> {
let uri = self.base_url.pathjoin("mod/activity");
let since_unix: u32 = match since.duration_since(UNIX_EPOCH) {
Author
Owner

maybe combine this logic into a func since it's used in multiple places

maybe combine this logic into a func since it's used in multiple places
treadful marked this conversation as resolved
@ -738,0 +822,4 @@
query.push(("mod_short_id", mod_short_id));
query.push(("since", since_unix.to_string()));
if let Some(kid) = short_id_filter {
Author
Owner

kid?

kid?
treadful marked this conversation as resolved
@ -738,0 +834,4 @@
.header(AUTHORIZATION, format!("basic {}", signature))
.send()
{
Ok(resp) => {
Author
Owner

Can we somehow reuse this whole match body with other API funcs?

Can we somehow reuse this whole match body with other API funcs?
treadful marked this conversation as resolved
@ -43,3 +43,3 @@
pub log_level: Level,
/// The key's content to serve at the server root
/// The key's to grant admin rights, and to serve its content at the server
Author
Owner

*key

*key
treadful marked this conversation as resolved
@ -81,0 +96,4 @@
.collect::<Vec<String>>();
for act in actions {
acts.push_bind(act);
}*/
Author
Owner

cleanup

cleanup
treadful marked this conversation as resolved
@ -0,0 +18,4 @@
context.req.query::<String>("mod_short_id").ok_or_else(|| {
warn!("Unauthorized: mod_short_id");
ResponseError::Unauthorized
})?;
Author
Owner

Does this make more sense if we use the nonce from the slip? It's already give to the user, and doesn't have a chance to cause a collision.

Does this make more sense if we use the nonce from the slip? It's already give to the user, and doesn't have a chance to cause a collision.
treadful marked this conversation as resolved
fix(client): compile error, func should be behind feature flag
All checks were successful
/ test-and-check (pull_request) Successful in 18m2s
42c8f8641e
@ -735,0 +508,4 @@
warn!(
status_code = resp.status().to_string(),
"Unhandled status"
);
Author
Owner

redundant warning, when the error is output to the user anyway

redundant warning, when the error is output to the user anyway
treadful marked this conversation as resolved
@ -735,0 +523,4 @@
limit: u32,
since: &Timestamp,
short_id_filter: &Option<String>,
mod_short_id: String,
Author
Owner

mod_short_id is no longer used by the server

`mod_short_id` is no longer used by the server
treadful marked this conversation as resolved
@ -735,0 +533,4 @@
let mut query = Vec::new();
query.push(("limit", limit.to_string()));
query.push(("mod_short_id", mod_short_id));
query.push(("since", since_unix.to_string()));
Author
Owner

vec![("limit", limit.to_string()), ("mod_short_id", mod_short_id), ("since", since_unix.to_string()]

`vec![("limit", limit.to_string()), ("mod_short_id", mod_short_id), ("since", since_unix.to_string()]`
treadful marked this conversation as resolved
@ -44,1 +47,3 @@
let slip = match client.admin_auth_audit_log() {
let slip = match client.slip_auth(
&key.keyid(),
Authorization::LIST,
Author
Owner

This should fail? The op is clearly not audit log cleaning related.

This should fail? The op is clearly not audit log cleaning related.
treadful marked this conversation as resolved
@ -0,0 +46,4 @@
error!(error = err, "Failed to open keyfile");
out::exit("Unable to open keyfile", 1);
}
};
Author
Owner

maybe do map_err for these?

maybe do `map_err` for these?
@ -0,0 +117,4 @@
}
// make sure the key isn't expired
if key_meta.config.expire > 0
Author
Owner

confirm that expire == 0 is unlimited

confirm that expire == 0 is unlimited
Author
Owner

Confirmed. The std Default trait implements this to be 0 for uints.

Confirmed. The std `Default` trait implements this to be `0` for uints.
treadful marked this conversation as resolved
@ -0,0 +19,4 @@
let short_id_filter = context.req.query::<String>("short_id");
let key_meta = slip_auth::authorize(context, Authorization::MOD).await?;
if !context.is_mod(&key_meta.key_id) {
Author
Owner

this check is redundant now?

this check is redundant now?
treadful marked this conversation as resolved
@ -0,0 +28,4 @@
Some(sss) => UNIX_EPOCH + Duration::from_secs(sss.into()),
None => SystemTime::now() - Duration::from_hours(24),
};
let action_filters = vec![
Author
Owner

add a note saying these are the actions the mods are allowed to see

add a note saying these are the actions the mods are allowed to see
treadful marked this conversation as resolved
@ -0,0 +51,4 @@
.audit_log_insert(
key_meta.key_id.to_short_hexstring(),
request_address(&context),
AuditAction::AuditLogList,
Author
Owner

consider if this should be a mod action, even though it's effectively the same thing

consider if this should be a mod action, even though it's effectively the same thing
@ -0,0 +1,33 @@
use std::collections::HashMap;
Author
Owner

I believe this file is now garbage. Look for other orphans from auth.

I believe this file is now garbage. Look for other orphans from auth.
treadful marked this conversation as resolved
@ -102,0 +135,4 @@
ResponseError::Forbidden
}
AuthError::Unexpected(msg) => {
error!(msg = msg, "Unexpected slip auth failure");
Author
Owner

"Unexpected auth failure"

"Unexpected auth failure"
treadful marked this conversation as resolved
jot/src/types.rs Outdated
@ -138,9 +142,45 @@ pub enum Authorization {
pub struct Slip {
pub nonce: String,
pub op: Authorization,
pub params: HashMap<String, String>,
Author
Owner

Use AuthParams

Use `AuthParams`
treadful marked this conversation as resolved
jot/src/types.rs Outdated
@ -144,0 +166,4 @@
}
}
impl Hash for AuthorizationRequest {
Author
Owner

Didn't end up using hashing here. Delete?

Didn't end up using hashing here. Delete?
treadful marked this conversation as resolved
jot/src/types.rs Outdated
@ -168,6 +214,7 @@ pub struct AllowDenyList {
pub root_key: Option<String>,
pub allow: HashSet<String>,
pub deny: HashSet<String>,
pub moderator: HashSet<String>,
Author
Owner

mods?

`mods`?
treadful marked this conversation as resolved
treadful deleted branch feat/mod 2026-06-24 03:57:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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
treadful/jot!125
No description provided.