Compare commits
No commits in common. "e7e8653ce261478eb361c4ff825dfc0dd4f090f4" and "93f61ea0dee9699103f9eefbb0e6885c5350baf9" have entirely different histories.
e7e8653ce2
...
93f61ea0de
13 changed files with 230 additions and 287 deletions
448
Cargo.lock
generated
448
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -35,7 +35,7 @@ clap = { version = "4.5", features = ["derive"] }
|
|||
signal-hook = "0.3"
|
||||
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
|
||||
tokio = { version = "1.35", features = ["full"] } # TODO slim this down
|
||||
sea-orm = { version = "1.0", features = ["sqlx-sqlite", "sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
sea-orm = { version = "0.12", features = ["sqlx-sqlite", "sqlx-postgres", "runtime-tokio-rustls"] }
|
||||
futures = "0.3"
|
||||
|
||||
upub = { path = "upub/core" }
|
||||
|
|
|
@ -19,7 +19,7 @@ thiserror = "1"
|
|||
paste = "1.0"
|
||||
tracing = "0.1"
|
||||
serde_json = { version = "1", optional = true }
|
||||
sea-orm = { version = "1.0", optional = true, default-features = false }
|
||||
sea-orm = { version = "0.12", optional = true, default-features = false }
|
||||
reqwest = { version = "0.12", features = ["json"], optional = true }
|
||||
|
||||
[features]
|
||||
|
|
|
@ -97,7 +97,7 @@ macro_rules! strenum {
|
|||
}
|
||||
|
||||
fn column_type() -> sea_orm::sea_query::ColumnType {
|
||||
sea_orm::sea_query::ColumnType::String(sea_orm::sea_query::table::StringLen::N(24))
|
||||
sea_orm::sea_query::ColumnType::String(Some(24))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ uuid = { version = "1.8", features = ["v4"] }
|
|||
chrono = { version = "0.4", features = ["serde"] }
|
||||
openssl = "0.10" # TODO handle pubkeys with a smaller crate
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
sea-orm = "1.0"
|
||||
sea-orm = "0.12"
|
||||
futures = "0.3"
|
||||
mdhtml = { path = "../../utils/mdhtml/" }
|
||||
|
|
|
@ -31,7 +31,7 @@ httpsign = { path = "../../utils/httpsign/" }
|
|||
mdhtml = { path = "../../utils/mdhtml/" }
|
||||
jrd = "0.1"
|
||||
tracing = "0.1"
|
||||
sea-orm = { version = "1.0", features = ["macros"] }
|
||||
sea-orm = { version = "0.12", features = ["macros"] }
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
apb = { path = "../../apb", features = ["unstructured", "orm", "did-core", "activitypub-miscellaneous-terms", "activitypub-fe", "activitypub-counters", "litepub", "ostatus", "toot"] }
|
||||
# nodeinfo = "0.0.2" # the version on crates.io doesn't re-export necessary types to build the struct!!!
|
||||
|
|
|
@ -12,9 +12,6 @@ pub struct Config {
|
|||
#[serde(default)]
|
||||
pub security: SecurityConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub compat: CompatibilityConfig,
|
||||
|
||||
// TODO should i move app keys here?
|
||||
}
|
||||
|
||||
|
@ -99,15 +96,6 @@ pub struct SecurityConfig {
|
|||
pub reinsertion_attempt_limit: u32,
|
||||
}
|
||||
|
||||
#[serde_inline_default::serde_inline_default]
|
||||
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, serde_default::DefaultFromSerde)]
|
||||
pub struct CompatibilityConfig {
|
||||
#[serde(default)]
|
||||
pub fix_attachment_images_media_type: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub add_explicit_target_to_likes_if_local: bool,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load(path: Option<&std::path::PathBuf>) -> Self {
|
||||
|
|
|
@ -12,8 +12,7 @@ where
|
|||
T::Model : Sync,
|
||||
{
|
||||
async fn any(self, db: &impl ConnectionTrait) -> Result<bool, sea_orm::DbErr> {
|
||||
// TODO ConnectionTrait became an iterator?? self.count(db) gives error now
|
||||
Ok(PaginatorTrait::count(self, db).await? > 0)
|
||||
Ok(self.count(db).await? > 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,6 +80,14 @@ impl Normalizer for crate::Context {
|
|||
tracing::warn!("ignoring array-in-array while processing attachments");
|
||||
continue
|
||||
},
|
||||
Node::Link(l) => crate::model::attachment::ActiveModel {
|
||||
internal: sea_orm::ActiveValue::NotSet,
|
||||
url: Set(self.cloaked(l.href().unwrap_or_default())),
|
||||
object: Set(object_model.internal),
|
||||
document_type: Set(apb::DocumentType::Page),
|
||||
name: Set(l.name().str()),
|
||||
media_type: Set(l.media_type().unwrap_or("link").to_string()),
|
||||
},
|
||||
Node::Object(o) => {
|
||||
let mut model = AP::attachment_q(o.as_document()?, object_model.internal, None)?;
|
||||
if let Set(u) | Unchanged(u) = model.url {
|
||||
|
@ -87,28 +95,6 @@ impl Normalizer for crate::Context {
|
|||
}
|
||||
model
|
||||
},
|
||||
Node::Link(l) => {
|
||||
let url = l.href().unwrap_or_default();
|
||||
let mut media_type = l.media_type().unwrap_or("link").to_string();
|
||||
let mut document_type = apb::DocumentType::Page;
|
||||
if self.cfg().compat.fix_attachment_images_media_type
|
||||
&& [".jpg", ".jpeg", ".png", ".webp", ".bmp"] // TODO more image types???
|
||||
.iter()
|
||||
.any(|x| url.ends_with(x))
|
||||
{
|
||||
document_type = apb::DocumentType::Image;
|
||||
media_type = format!("image/{}", url.split('.').last().unwrap_or_default());
|
||||
|
||||
}
|
||||
crate::model::attachment::ActiveModel {
|
||||
internal: sea_orm::ActiveValue::NotSet,
|
||||
url: Set(self.cloaked(url)),
|
||||
object: Set(object_model.internal),
|
||||
document_type: Set(document_type),
|
||||
name: Set(l.name().str()),
|
||||
media_type: Set(media_type),
|
||||
}
|
||||
},
|
||||
};
|
||||
crate::model::attachment::Entity::insert(attachment_model)
|
||||
.exec(tx)
|
||||
|
|
|
@ -98,7 +98,6 @@ pub async fn create(ctx: &crate::Context, activity: impl apb::Activity, tx: &Dat
|
|||
pub async fn like(ctx: &crate::Context, activity: impl apb::Activity, tx: &DatabaseTransaction) -> Result<(), ProcessorError> {
|
||||
let actor = ctx.fetch_user(activity.actor().id()?, tx).await?;
|
||||
let obj = ctx.fetch_object(activity.object().id()?, tx).await?;
|
||||
let likes_local_object = obj.attributed_to.as_ref().map(|x| ctx.is_local(x)).unwrap_or_default();
|
||||
if crate::model::like::Entity::find_by_uid_oid(actor.internal, obj.internal)
|
||||
.any(tx)
|
||||
.await?
|
||||
|
@ -121,11 +120,8 @@ pub async fn like(ctx: &crate::Context, activity: impl apb::Activity, tx: &Datab
|
|||
.await?;
|
||||
|
||||
// likes without addressing are "silent likes", process them but dont store activity or notify
|
||||
if likes_local_object || !activity.addressed().is_empty() {
|
||||
let mut activity_model = ctx.insert_activity(activity, tx).await?;
|
||||
if likes_local_object {
|
||||
activity_model.to.0.push(obj.attributed_to.clone().unwrap_or_default());
|
||||
}
|
||||
if !activity.addressed().is_empty() {
|
||||
let activity_model = ctx.insert_activity(activity, tx).await?;
|
||||
ctx.address((Some(&activity_model), None), tx).await?;
|
||||
|
||||
// TODO check that object author is in this like addressing!!! otherwise skip notification
|
||||
|
|
|
@ -11,4 +11,4 @@ readme = "README.md"
|
|||
[lib]
|
||||
|
||||
[dependencies]
|
||||
sea-orm-migration = "1.0"
|
||||
sea-orm-migration = "0.12"
|
||||
|
|
|
@ -27,7 +27,7 @@ tower-http = { version = "0.5", features = ["cors", "trace"] }
|
|||
httpsign = { path = "../../utils/httpsign/", features = ["axum"] }
|
||||
apb = { path = "../../apb", features = ["unstructured", "orm", "activitypub-fe", "activitypub-counters", "litepub", "ostatus", "toot", "jsonld"] }
|
||||
uriproxy = { path = "../../utils/uriproxy" }
|
||||
sea-orm = "1.0"
|
||||
sea-orm = { version = "0.12", features = ["macros", "sqlx-sqlite", "runtime-tokio-rustls"] }
|
||||
# nodeinfo = "0.0.2" # the version on crates.io doesn't re-export necessary types to build the struct!!!
|
||||
nodeinfo = { git = "https://codeberg.org/thefederationinfo/nodeinfo-rs", rev = "e865094804" }
|
||||
# mastodon
|
||||
|
|
|
@ -15,7 +15,7 @@ thiserror = "1"
|
|||
tracing = "0.1"
|
||||
async-trait = "0.1"
|
||||
serde_json = "1"
|
||||
sea-orm = "1.0"
|
||||
sea-orm = "0.12"
|
||||
regex = "1.10"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
tokio = { version = "1.35", features = ["full"] } # TODO slim this down
|
||||
|
|
Loading…
Reference in a new issue