a06673b
use db::conn::sea_orm::*;
use db::issue::stopwatch as sw_entity;
use uuid::Uuid;
use crate::error::{IssueError, IssueResult};
use crate::features::IssueService;
pub fn require_authenticated(actor: Uuid) -> IssueResult<()> {
if actor.is_nil() {
return Err(IssueError::Unauthorized("authentication required".into()));
}
Ok(())
}
pub async fn load_my_stopwatch(
svc: &IssueService,
issue_id: Uuid,
user_id: Uuid,
) -> IssueResult<sw_entity::Model> {
let db = svc.db.reader();
let s = sw_entity::Entity::find()
.filter(sw_entity::COLUMN.issue_id.eq(issue_id))
.filter(sw_entity::COLUMN.user_id.eq(user_id))
.one(&db)
.await?
.ok_or_else(|| IssueError::NotFound("stopwatch".into()))?;
Ok(s)
}