forked from coracle/caravel
Format, lint, check
This commit is contained in:
+6
-3
@@ -161,7 +161,7 @@ impl Api {
|
|||||||
.map_err(ApiError::Unauthorized)?;
|
.map_err(ApiError::Unauthorized)?;
|
||||||
|
|
||||||
let mut got_u = None::<String>;
|
let mut got_u = None::<String>;
|
||||||
for tag in &event.tags {
|
for tag in event.tags.iter() {
|
||||||
let values = tag.as_slice();
|
let values = tag.as_slice();
|
||||||
if values.len() >= 2 && values[0] == "u" {
|
if values.len() >= 2 && values[0] == "u" {
|
||||||
got_u = Some(values[1].to_string());
|
got_u = Some(values[1].to_string());
|
||||||
@@ -173,7 +173,9 @@ impl Api {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if !self.host.is_empty() && !got_u.contains(&self.host) {
|
if !self.host.is_empty() && !got_u.contains(&self.host) {
|
||||||
return Err(ApiError::Unauthorized(anyhow!("authorization host mismatch")));
|
return Err(ApiError::Unauthorized(anyhow!(
|
||||||
|
"authorization host mismatch"
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(event.pubkey.to_hex())
|
Ok(event.pubkey.to_hex())
|
||||||
@@ -192,7 +194,8 @@ impl Api {
|
|||||||
authorized_pubkey: &str,
|
authorized_pubkey: &str,
|
||||||
tenant_pubkey: &str,
|
tenant_pubkey: &str,
|
||||||
) -> std::result::Result<(), ApiError> {
|
) -> std::result::Result<(), ApiError> {
|
||||||
if self.admins.iter().any(|a| a == authorized_pubkey) || authorized_pubkey == tenant_pubkey {
|
if self.admins.iter().any(|a| a == authorized_pubkey) || authorized_pubkey == tenant_pubkey
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(ApiError::Forbidden("not authorized"))
|
Err(ApiError::Forbidden("not authorized"))
|
||||||
|
|||||||
+5
-1
@@ -481,7 +481,11 @@ impl Repo {
|
|||||||
Ok(rows)
|
Ok(rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_activity_for_tenant(&self, tenant: &str, since: &i64) -> Result<Vec<Activity>> {
|
pub async fn list_activity_for_tenant(
|
||||||
|
&self,
|
||||||
|
tenant: &str,
|
||||||
|
since: &i64,
|
||||||
|
) -> Result<Vec<Activity>> {
|
||||||
let rows = sqlx::query_as::<_, Activity>(
|
let rows = sqlx::query_as::<_, Activity>(
|
||||||
"SELECT id, tenant, created_at, activity_type, resource_type, resource_id
|
"SELECT id, tenant, created_at, activity_type, resource_type, resource_id
|
||||||
FROM activity
|
FROM activity
|
||||||
|
|||||||
Reference in New Issue
Block a user