chore (backend-rs): rename stuff
This commit is contained in:
parent
8234858ab7
commit
7e9db5fcff
12 changed files with 49 additions and 49 deletions
|
@ -5,19 +5,19 @@ use uuid::Uuid;
|
|||
#[macros::export(object)]
|
||||
pub struct ApAccept {
|
||||
pub id: String,
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub object: follow::ApFollow,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApAccept {}
|
||||
impl ApObject for ApAccept {}
|
||||
|
||||
impl ApAccept {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(user_id: String, follow_object: follow::ApFollow) -> Self {
|
||||
Self {
|
||||
id: format!("{}/{}", CONFIG.url, Uuid::new_v4()),
|
||||
r#type: ApObject::Accept,
|
||||
r#type: Activity::Accept,
|
||||
actor: user::local_uri(user_id),
|
||||
object: follow_object,
|
||||
}
|
||||
|
|
|
@ -5,22 +5,22 @@ use crate::misc::{note, user};
|
|||
|
||||
#[macros::export(object)]
|
||||
pub struct ApAdd {
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub target: String,
|
||||
pub object: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApAdd {}
|
||||
impl ApObject for ApAdd {}
|
||||
|
||||
impl ApAdd {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(user_id: String, note_id: String) -> Self {
|
||||
let actor_uri = user::local_uri(user_id);
|
||||
let collection_uri = format!("{}/collections/featured", actor_uri);
|
||||
|
||||
Self {
|
||||
r#type: ApObject::Add,
|
||||
r#type: Activity::Add,
|
||||
actor: actor_uri,
|
||||
target: collection_uri,
|
||||
object: note::local_uri(note_id),
|
||||
|
|
|
@ -5,7 +5,7 @@ use chrono::Utc;
|
|||
#[macros::export(object)]
|
||||
pub struct ApEmoji {
|
||||
pub id: String,
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub name: String,
|
||||
pub updated: String,
|
||||
pub icon: Icon,
|
||||
|
@ -13,25 +13,25 @@ pub struct ApEmoji {
|
|||
|
||||
#[macros::export(object)]
|
||||
pub struct Icon {
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub media_type: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApEmoji {}
|
||||
impl ApObject for ApEmoji {}
|
||||
|
||||
impl ApEmoji {
|
||||
pub fn new(emoji: emoji::Model) -> Self {
|
||||
Self {
|
||||
id: misc::emoji::local_uri(&emoji.name),
|
||||
r#type: ApObject::Emoji,
|
||||
r#type: Activity::Emoji,
|
||||
name: format!(":{}:", emoji.name),
|
||||
updated: emoji
|
||||
.updated_at
|
||||
.unwrap_or_else(|| Utc::now().into())
|
||||
.to_rfc3339(),
|
||||
icon: Icon {
|
||||
r#type: ApObject::Image,
|
||||
r#type: Activity::Image,
|
||||
media_type: emoji.r#type.unwrap_or_else(|| "image/png".to_owned()),
|
||||
url: emoji.public_url,
|
||||
},
|
||||
|
|
|
@ -3,23 +3,23 @@ use crate::{federation::internal_actor, misc::user};
|
|||
|
||||
#[macros::export(object)]
|
||||
pub struct ApFlag {
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub content: String,
|
||||
// TODO: object can be an array of uri's
|
||||
pub object: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApFlag {}
|
||||
impl ApObject for ApFlag {}
|
||||
|
||||
impl ApFlag {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
async fn new(
|
||||
target_user_uri: String,
|
||||
comment: String,
|
||||
) -> Result<Self, internal_actor::instance::Error> {
|
||||
Ok(Self {
|
||||
r#type: ApObject::Flag,
|
||||
r#type: Activity::Flag,
|
||||
actor: user::local_uri(&internal_actor::instance::get().await?.id),
|
||||
content: comment,
|
||||
object: target_user_uri,
|
||||
|
|
|
@ -4,12 +4,12 @@ use crate::{config::CONFIG, federation::internal_actor, misc::user};
|
|||
#[macros::export(object)]
|
||||
pub struct ApFollow {
|
||||
pub id: String,
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub object: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApFollow {}
|
||||
impl ApObject for ApFollow {}
|
||||
|
||||
#[macros::errors]
|
||||
pub enum Error {
|
||||
|
@ -20,7 +20,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl ApFollow {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(
|
||||
follower: UserLike,
|
||||
followee: UserLike,
|
||||
|
@ -30,7 +30,7 @@ impl ApFollow {
|
|||
id: request_id.unwrap_or_else(|| {
|
||||
format!("{}/follows/{}/{}", CONFIG.url, follower.id, followee.id)
|
||||
}),
|
||||
r#type: ApObject::Follow,
|
||||
r#type: Activity::Follow,
|
||||
actor: match user::is_local!(follower) {
|
||||
true => user::local_uri(follower.id),
|
||||
false => follower.uri.ok_or(Error::MissingFollowerUri)?,
|
||||
|
@ -42,11 +42,11 @@ impl ApFollow {
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
async fn new_relay(relay_id: String) -> Result<Self, internal_actor::relay::Error> {
|
||||
Ok(Self {
|
||||
id: format!("{}/activities/follow-relay/{}", CONFIG.url, relay_id),
|
||||
r#type: ApObject::Follow,
|
||||
r#type: Activity::Follow,
|
||||
actor: user::local_uri(internal_actor::relay::get_id().await?),
|
||||
object: AS_PUBLIC_URL.to_owned(),
|
||||
})
|
||||
|
|
|
@ -4,18 +4,18 @@ use crate::config::CONFIG;
|
|||
#[macros::export(object)]
|
||||
pub struct ApHashtag {
|
||||
pub id: String,
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApHashtag {}
|
||||
impl ApObject for ApHashtag {}
|
||||
|
||||
impl ApHashtag {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(tag_name: &str) -> Self {
|
||||
Self {
|
||||
id: format!("{}/tags/{}", CONFIG.url, urlencoding::encode(tag_name)),
|
||||
r#type: ApObject::Hashtag,
|
||||
r#type: Activity::Hashtag,
|
||||
name: format!("#{}", tag_name),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,17 +20,17 @@ pub enum Error {
|
|||
#[macros::export(object, use_nullable = false)]
|
||||
pub struct ApLike {
|
||||
pub id: String,
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub object: String,
|
||||
pub content: String,
|
||||
pub tag: Option<Vec<ApEmoji>>,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApLike {}
|
||||
impl ApObject for ApLike {}
|
||||
|
||||
impl ApLike {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
async fn new(reaction: note_reaction::Model) -> Result<Self, Error> {
|
||||
let db = db_conn().await?;
|
||||
|
||||
|
@ -59,7 +59,7 @@ impl ApLike {
|
|||
|
||||
Ok(Self {
|
||||
id: format!("{}/likes/{}", CONFIG.url, reaction.id),
|
||||
r#type: ApObject::Like,
|
||||
r#type: Activity::Like,
|
||||
actor: user::local_uri(reaction.user_id),
|
||||
object: note_uri,
|
||||
content: reaction.reaction,
|
||||
|
|
|
@ -7,18 +7,18 @@ pub struct MissingRemoteUserUri;
|
|||
|
||||
#[macros::export(object)]
|
||||
pub struct ApMention {
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub href: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApMention {}
|
||||
impl ApObject for ApMention {}
|
||||
|
||||
impl ApMention {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(user: UserLike) -> Result<Self, MissingRemoteUserUri> {
|
||||
Ok(Self {
|
||||
r#type: ApObject::Mention,
|
||||
r#type: Activity::Mention,
|
||||
href: match user::is_local!(user) {
|
||||
true => user::local_uri(user.id),
|
||||
false => user.uri.ok_or(MissingRemoteUserUri)?,
|
||||
|
|
|
@ -10,10 +10,10 @@ pub mod read;
|
|||
pub mod remove;
|
||||
pub mod tombstone;
|
||||
|
||||
pub trait ActivityPubObject {}
|
||||
pub trait ApObject {}
|
||||
|
||||
#[macros::export(string_enum)]
|
||||
pub enum ApObject {
|
||||
pub enum Activity {
|
||||
Accept,
|
||||
Add,
|
||||
Emoji,
|
||||
|
|
|
@ -3,18 +3,18 @@ use crate::misc::user;
|
|||
|
||||
#[macros::export(object)]
|
||||
pub struct ApRead {
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub object: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApRead {}
|
||||
impl ApObject for ApRead {}
|
||||
|
||||
impl ApRead {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(user_id: String, message_uri: String) -> Self {
|
||||
Self {
|
||||
r#type: ApObject::Read,
|
||||
r#type: Activity::Read,
|
||||
actor: user::local_uri(user_id),
|
||||
object: message_uri,
|
||||
}
|
||||
|
|
|
@ -5,22 +5,22 @@ use crate::misc::{note, user};
|
|||
|
||||
#[macros::export(object)]
|
||||
pub struct ApRemove {
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
pub actor: String,
|
||||
pub target: String,
|
||||
pub object: String,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApRemove {}
|
||||
impl ApObject for ApRemove {}
|
||||
|
||||
impl ApRemove {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(user_id: String, note_id: String) -> Self {
|
||||
let actor_uri = user::local_uri(user_id);
|
||||
let collection_uri = format!("{}/collections/featured", actor_uri);
|
||||
|
||||
Self {
|
||||
r#type: ApObject::Remove,
|
||||
r#type: Activity::Remove,
|
||||
actor: actor_uri,
|
||||
target: collection_uri,
|
||||
object: note::local_uri(note_id),
|
||||
|
|
|
@ -4,17 +4,17 @@ use crate::misc::note;
|
|||
#[macros::export(object)]
|
||||
pub struct ApTombstone {
|
||||
pub id: String,
|
||||
pub r#type: ApObject,
|
||||
pub r#type: Activity,
|
||||
}
|
||||
|
||||
impl ActivityPubObject for ApTombstone {}
|
||||
impl ApObject for ApTombstone {}
|
||||
|
||||
impl ApTombstone {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
#[allow(dead_code)] // TODO: remove this line by actually using it
|
||||
fn new(note_id: String) -> Self {
|
||||
Self {
|
||||
id: note::local_uri(note_id),
|
||||
r#type: ApObject::Tombstone,
|
||||
r#type: Activity::Tombstone,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue