1
Fork 0

Create webfinger crate #5

Merged
steffo merged 53 commits from feature/webfinger into main 2024-11-16 06:33:06 +00:00
Showing only changes of commit 8a49903eca - Show all commits

View file

@ -22,6 +22,7 @@ pub struct MetaLink {
pub rel: String, pub rel: String,
pub type_: Option<String>, pub type_: Option<String>,
pub href: Option<String>, pub href: Option<String>,
pub template: Option<String>,
} }
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)] #[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)]
@ -34,6 +35,16 @@ pub struct MetaLinkProperty {
pub value: Option<String>, pub value: Option<String>,
} }
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)]
#[diesel(belongs_to(MetaLink))]
#[diesel(table_name = schema::meta_link_titles)]
pub struct MetaLinkTitle {
pub id: Uuid,
pub meta_link_id: Uuid,
pub language: String,
pub value: String,
}
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)] #[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)]
#[diesel(table_name = schema::meta_properties)] #[diesel(table_name = schema::meta_properties)]
pub struct MetaProperty { pub struct MetaProperty {
@ -44,7 +55,6 @@ pub struct MetaProperty {
pub value: Option<String>, pub value: Option<String>,
} }
impl MetaAlias { impl MetaAlias {
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<MetaAlias>> { pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<MetaAlias>> {
use diesel::prelude::*; use diesel::prelude::*;
@ -88,6 +98,15 @@ impl MetaLink {
.load(conn) .load(conn)
.await .await
} }
pub async fn query_titles(&self, conn: &mut AsyncPgConnection) -> QueryResult<Vec<MetaLinkTitle>> {
use diesel::prelude::*;
use diesel_async::RunQueryDsl;
MetaLinkTitle::belonging_to(self)
.load(conn)
.await
}
} }
impl MetaProperty { impl MetaProperty {