Skip to content

Commit

Permalink
Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Mar 11, 2023
1 parent 81e10b8 commit 66e0c8d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 145 deletions.
1 change: 0 additions & 1 deletion lib/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::{
email::{self, MailMessage},
endpoints::{default_endpoints, Endpoint, HandleGetContext},
errors::{AtomicError, AtomicResult},
plugins::default_endpoints,
query::QueryResult,
resources::PropVals,
storelike::Storelike,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Examples of endpoints are versions for resources, or (pages for) collections.
//! See https://docs.atomicdata.dev/endpoints.html or https://atomicdata.dev/classes/Endpoint

use crate::{errors::AtomicResult, urls, Db, Resource, Storelike, Value};
use crate::{errors::AtomicResult, plugins, urls, Db, Resource, Storelike, Value};

/// The function that is called when a POST request matches the path
type HandleGet = fn(context: HandleGetContext) -> AtomicResult<Resource>;
Expand Down
28 changes: 15 additions & 13 deletions lib/src/plugins/add_pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use serde::{Deserialize, Serialize};
use crate::{
agents::Agent,
email::{EmailAddress, MailAction, MailMessage},
endpoints::Endpoint,
endpoints::{Endpoint, HandleGetContext},
errors::AtomicResult,
plugins::utils::return_success,
urls, Db, Resource, Storelike,
urls, Resource, Storelike,
};

pub fn request_email_add_pubkey() -> Endpoint {
Expand Down Expand Up @@ -41,11 +41,12 @@ struct AddPubkeyToken {
agent: String,
}

pub fn handle_request_email_pubkey(
url: url::Url,
store: &Db,
_for_agent: Option<&str>,
) -> AtomicResult<Resource> {
pub fn handle_request_email_pubkey(context: HandleGetContext) -> AtomicResult<Resource> {
let HandleGetContext {
subject: url,
store,
for_agent: _,
} = context;
let mut email_option: Option<EmailAddress> = None;
for (k, v) in url.query_pairs() {
if let "email" = k.as_ref() {
Expand Down Expand Up @@ -98,12 +99,13 @@ pub fn handle_request_email_pubkey(
return_success()
}

#[tracing::instrument(skip(store))]
pub fn handle_confirm_add_pubkey(
url: url::Url,
store: &Db,
for_agent: Option<&str>,
) -> AtomicResult<Resource> {
#[tracing::instrument]
pub fn handle_confirm_add_pubkey(context: HandleGetContext) -> AtomicResult<Resource> {
let HandleGetContext {
subject: url,
store,
for_agent: _,
} = context;
let mut token_opt: Option<String> = None;
let mut pubkey_option = None;

Expand Down
130 changes: 0 additions & 130 deletions lib/src/plugins/reset_pubkey.rs

This file was deleted.

18 changes: 18 additions & 0 deletions server/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,21 @@ pub fn get_subject(
let subject = format!("{}{}", server_without_last_slash, &req.uri().to_string());
Ok(subject)
}

/// Finds the extension
pub fn try_extension(path: &str) -> Option<(ContentType, &str)> {
let items: Vec<&str> = path.split('.').collect();
if items.len() == 2 {
let path = items[0];
let content_type = match items[1] {
"json" => ContentType::Json,
"jsonld" => ContentType::JsonLd,
"jsonad" => ContentType::JsonAd,
"html" => ContentType::Html,
"ttl" => ContentType::Turtle,
_ => return None,
};
return Some((content_type, path));
}
None
}

0 comments on commit 66e0c8d

Please sign in to comment.