1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 06:01:09 +00:00

Fix problems with invalid apub ids

This commit is contained in:
Felix Ableitner 2024-03-11 13:40:03 +01:00
parent 11c3971d9e
commit 0b2bfbd3ae
7 changed files with 12 additions and 127 deletions

4
Cargo.lock generated
View file

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "activitypub_federation" name = "activitypub_federation"
version = "0.5.1" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eee115a53849bbcac6c953495b5f9322b56680c0a1bdef6813183f0453f9ee3c" checksum = "a028034c642d3ed16b535f98f48b3df30397833c183d68852d79de16650d5ed5"
dependencies = [ dependencies = [
"activitystreams-kinds", "activitystreams-kinds",
"async-trait", "async-trait",

View file

@ -26,7 +26,7 @@ dbg_macro = "deny"
unwrap_used = "deny" unwrap_used = "deny"
[dependencies] [dependencies]
activitypub_federation = { version = "0.5.1", features = [ activitypub_federation = { version = "0.5.2", features = [
"axum", "axum",
"diesel", "diesel",
], default-features = false, optional = true } ], default-features = false, optional = true }

View file

@ -25,6 +25,7 @@ main {
.item-view { .item-view {
padding: 0 20px 20px 20px; padding: 0 20px 20px 20px;
max-width: 700px;
} }
pre { pre {

View file

@ -3,8 +3,8 @@ create table instance (
domain text not null unique, domain text not null unique,
ap_id varchar(255) not null unique, ap_id varchar(255) not null unique,
description text, description text,
inbox_url text not null,
articles_url varchar(255) not null unique, articles_url varchar(255) not null unique,
inbox_url varchar(255) not null,
public_key text not null, public_key text not null,
private_key text, private_key text,
last_refreshed_at timestamptz not null default now(), last_refreshed_at timestamptz not null default now(),
@ -15,7 +15,7 @@ create table person (
id serial primary key, id serial primary key,
username text not null, username text not null,
ap_id varchar(255) not null unique, ap_id varchar(255) not null unique,
inbox_url text not null, inbox_url varchar(255) not null,
public_key text not null, public_key text not null,
private_key text, private_key text,
last_refreshed_at timestamptz not null default now(), last_refreshed_at timestamptz not null default now(),

View file

@ -47,9 +47,10 @@ diesel::table! {
#[max_length = 255] #[max_length = 255]
ap_id -> Varchar, ap_id -> Varchar,
description -> Nullable<Text>, description -> Nullable<Text>,
inbox_url -> Text,
#[max_length = 255] #[max_length = 255]
articles_url -> Varchar, articles_url -> Varchar,
#[max_length = 255]
inbox_url -> Varchar,
public_key -> Text, public_key -> Text,
private_key -> Nullable<Text>, private_key -> Nullable<Text>,
last_refreshed_at -> Timestamptz, last_refreshed_at -> Timestamptz,
@ -88,7 +89,8 @@ diesel::table! {
username -> Text, username -> Text,
#[max_length = 255] #[max_length = 255]
ap_id -> Varchar, ap_id -> Varchar,
inbox_url -> Text, #[max_length = 255]
inbox_url -> Varchar,
public_key -> Text, public_key -> Text,
private_key -> Nullable<Text>, private_key -> Nullable<Text>,
last_refreshed_at -> Timestamptz, last_refreshed_at -> Timestamptz,

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
backend::{database::IbisData, error::Error, federation::objects::edit::ApubEdit}, backend::{database::IbisData, error::Error, federation::objects::edit::ApubEdit},
common::{DbArticle, DbEdit, DbInstance}, common::{DbArticle, DbEdit},
}; };
use activitypub_federation::{ use activitypub_federation::{
config::Data, config::Data,
@ -45,10 +45,9 @@ impl Collection for DbEditCollection {
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
) )
.await?; .await?;
let local_instance = DbInstance::read_local_instance(data)?;
let collection = ApubEditCollection { let collection = ApubEditCollection {
r#type: Default::default(), r#type: Default::default(),
id: Url::from(local_instance.articles_url), id: Url::from(article.article.edits_id()?),
total_items: edits.len() as i32, total_items: edits.len() as i32,
items: edits, items: edits,
}; };

View file

@ -1,117 +0,0 @@
// @generated automatically by Diesel CLI.
diesel::table! {
article (id) {
id -> Int4,
title -> Text,
text -> Text,
#[max_length = 255]
ap_id -> Varchar,
instance_id -> Int4,
local -> Bool,
protected -> Bool,
}
}
diesel::table! {
conflict (id) {
id -> Int4,
hash -> Uuid,
diff -> Text,
summary -> Text,
creator_id -> Int4,
article_id -> Int4,
previous_version_id -> Uuid,
}
}
diesel::table! {
edit (id) {
id -> Int4,
creator_id -> Int4,
hash -> Uuid,
#[max_length = 255]
ap_id -> Varchar,
diff -> Text,
summary -> Text,
article_id -> Int4,
previous_version_id -> Uuid,
created -> Timestamptz,
}
}
diesel::table! {
instance (id) {
id -> Int4,
domain -> Text,
#[max_length = 255]
ap_id -> Varchar,
description -> Nullable<Text>,
inbox_url -> Text,
#[max_length = 255]
articles_url -> Varchar,
public_key -> Text,
private_key -> Nullable<Text>,
last_refreshed_at -> Timestamptz,
local -> Bool,
}
}
diesel::table! {
instance_follow (id) {
id -> Int4,
instance_id -> Int4,
follower_id -> Int4,
pending -> Bool,
}
}
diesel::table! {
jwt_secret (id) {
id -> Int4,
secret -> Varchar,
}
}
diesel::table! {
local_user (id) {
id -> Int4,
password_encrypted -> Text,
person_id -> Int4,
admin -> Bool,
}
}
diesel::table! {
person (id) {
id -> Int4,
username -> Text,
#[max_length = 255]
ap_id -> Varchar,
inbox_url -> Text,
public_key -> Text,
private_key -> Nullable<Text>,
last_refreshed_at -> Timestamptz,
local -> Bool,
}
}
diesel::joinable!(article -> instance (instance_id));
diesel::joinable!(conflict -> article (article_id));
diesel::joinable!(conflict -> local_user (creator_id));
diesel::joinable!(edit -> article (article_id));
diesel::joinable!(edit -> person (creator_id));
diesel::joinable!(instance_follow -> instance (instance_id));
diesel::joinable!(instance_follow -> person (follower_id));
diesel::joinable!(local_user -> person (person_id));
diesel::allow_tables_to_appear_in_same_query!(
article,
conflict,
edit,
instance,
instance_follow,
jwt_secret,
local_user,
person,
);