Simplify the Inbox trait
If we want to add, for instance, streams in the future, we could introduce a new trait for that, similar to FromActivity or Notify We also display inbox errors to the "client" if something fails, which could be useful for debugging.
This commit is contained in:
@@ -44,7 +44,8 @@ fn create_response(blog_name: String, slug: String, query: Option<CommentQuery>,
|
||||
.create(&*conn);
|
||||
|
||||
let instance = Instance::get_local(&*conn).unwrap();
|
||||
instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error"));
|
||||
instance.received(&*conn, serde_json::to_value(new_comment.clone()).expect("JSON serialization error"))
|
||||
.expect("We are not compatible with ourselve: local broadcast failed (new comment)");
|
||||
broadcast(&user, new_comment, user.get_followers(&*conn));
|
||||
|
||||
Redirect::to(format!("/~/{}/{}/#comment-{}", blog_name, slug, id))
|
||||
|
||||
@@ -35,8 +35,13 @@ fn index(conn: DbConn, user: Option<User>) -> Template {
|
||||
fn shared_inbox(conn: DbConn, data: String) -> String {
|
||||
let act: serde_json::Value = serde_json::from_str(&data[..]).unwrap();
|
||||
let instance = Instance::get_local(&*conn).unwrap();
|
||||
instance.received(&*conn, act);
|
||||
String::from("")
|
||||
match instance.received(&*conn, act) {
|
||||
Ok(_) => String::new(),
|
||||
Err(e) => {
|
||||
println!("Shared inbox error: {}\n{}", e.cause(), e.backtrace());
|
||||
format!("Error: {}", e.cause())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/nodeinfo")]
|
||||
|
||||
+7
-2
@@ -199,8 +199,13 @@ fn outbox(name: String, conn: DbConn) -> ActivityStream<OrderedCollection> {
|
||||
fn inbox(name: String, conn: DbConn, data: String) -> String {
|
||||
let user = User::find_local(&*conn, name).unwrap();
|
||||
let act: serde_json::Value = serde_json::from_str(&data[..]).unwrap();
|
||||
user.received(&*conn, act);
|
||||
String::from("")
|
||||
match user.received(&*conn, act) {
|
||||
Ok(_) => String::new(),
|
||||
Err(e) => {
|
||||
println!("User inbox error: {}\n{}", e.cause(), e.backtrace());
|
||||
format!("Error: {}", e.cause())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/@/<name>/followers", format = "application/activity+json")]
|
||||
|
||||
Reference in New Issue
Block a user