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