Webfinger
This commit is contained in:
@@ -3,6 +3,7 @@ use diesel::{QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||
use schema::blogs;
|
||||
use activity_pub::{Actor, ActorType};
|
||||
use models::instance::Instance;
|
||||
use activity_pub::webfinger::*;
|
||||
|
||||
#[derive(Queryable, Identifiable)]
|
||||
pub struct Blog {
|
||||
@@ -83,6 +84,33 @@ impl Actor for Blog {
|
||||
}
|
||||
}
|
||||
|
||||
impl Webfinger for Blog {
|
||||
fn webfinger_subject(&self, conn: &PgConnection) -> String {
|
||||
format!("acct:{}@{}", self.actor_id, self.get_instance(conn).public_domain)
|
||||
}
|
||||
fn webfinger_aliases(&self, conn: &PgConnection) -> Vec<String> {
|
||||
vec![self.compute_id(conn)]
|
||||
}
|
||||
fn webfinger_links(&self, conn: &PgConnection) -> Vec<Vec<(String, String)>> {
|
||||
vec![
|
||||
vec![
|
||||
(String::from("rel"), String::from("http://webfinger.net/rel/profile-page")),
|
||||
(String::from("href"), self.compute_id(conn))
|
||||
],
|
||||
vec![
|
||||
(String::from("rel"), String::from("http://schemas.google.com/g/2010#updates-from")),
|
||||
(String::from("type"), String::from("application/atom+xml")),
|
||||
(String::from("href"), self.compute_box(conn, "feed.atom"))
|
||||
],
|
||||
vec![
|
||||
(String::from("rel"), String::from("self")),
|
||||
(String::from("type"), String::from("application/activity+json")),
|
||||
(String::from("href"), self.compute_id(conn))
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl NewBlog {
|
||||
pub fn new_local(
|
||||
actor_id: String,
|
||||
|
||||
@@ -8,6 +8,7 @@ use db_conn::DbConn;
|
||||
use activity_pub::{ActorType, Actor};
|
||||
use models::instance::Instance;
|
||||
use bcrypt;
|
||||
use activity_pub::webfinger::Webfinger;
|
||||
|
||||
pub const AUTH_COOKIE: &'static str = "user_id";
|
||||
|
||||
@@ -127,6 +128,33 @@ impl Actor for User {
|
||||
}
|
||||
}
|
||||
|
||||
impl Webfinger for User {
|
||||
fn webfinger_subject(&self, conn: &PgConnection) -> String {
|
||||
format!("acct:{}@{}", self.username, self.get_instance(conn).public_domain)
|
||||
}
|
||||
fn webfinger_aliases(&self, conn: &PgConnection) -> Vec<String> {
|
||||
vec![self.compute_id(conn)]
|
||||
}
|
||||
fn webfinger_links(&self, conn: &PgConnection) -> Vec<Vec<(String, String)>> {
|
||||
vec![
|
||||
vec![
|
||||
(String::from("rel"), String::from("http://webfinger.net/rel/profile-page")),
|
||||
(String::from("href"), self.compute_id(conn))
|
||||
],
|
||||
vec![
|
||||
(String::from("rel"), String::from("http://schemas.google.com/g/2010#updates-from")),
|
||||
(String::from("type"), String::from("application/atom+xml")),
|
||||
(String::from("href"), self.compute_box(conn, "feed.atom"))
|
||||
],
|
||||
vec![
|
||||
(String::from("rel"), String::from("self")),
|
||||
(String::from("type"), String::from("application/activity+json")),
|
||||
(String::from("href"), self.compute_id(conn))
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impl NewUser {
|
||||
/// Creates a new local user
|
||||
pub fn new_local(
|
||||
|
||||
Reference in New Issue
Block a user