Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions plume-models/src/inbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub fn inbox(ctx: &PlumeRocket, act: serde_json::Value) -> Result<InboxResult, E
.with::<User, Create, Post>()
.with::<User, Delete, Comment>()
.with::<User, Delete, Post>()
.with::<User, Delete, User>()
.with::<User, Follow, User>()
.with::<User, Like, Post>()
.with::<User, Undo, Reshare>()
Expand Down Expand Up @@ -286,6 +287,34 @@ pub(crate) mod tests {
});
}

#[test]
fn delete_user() {
let r = rockets();
let conn = &*r.conn;
conn.test_transaction::<_, (), _>(|| {
let (_, users, _) = fill_database(&r);

let fail_act = json!({
"id": "https://plu.me/@/Admin#delete",
"actor": users[1].ap_url, // Not the same account
"object": users[0].ap_url,
"type": "Delete",
});
assert!(super::inbox(&r, fail_act).is_err());

let ok_act = json!({
"id": "https://plu.me/@/Admin#delete",
"actor": users[0].ap_url,
"object": users[0].ap_url,
"type": "Delete",
});
assert!(super::inbox(&r, ok_act).is_ok());
assert!(crate::users::User::get(conn, users[0].id).is_err());

Ok(())
});
}

#[test]
fn follow() {
let r = rockets();
Expand Down
34 changes: 31 additions & 3 deletions plume-models/src/users.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use activitypub::{
actor::Person, collection::OrderedCollection, object::Image, Activity, CustomObject, Endpoint,
activity::Delete, actor::Person, collection::OrderedCollection, object::{Image, Tombstone}, Activity, CustomObject, Endpoint,
};
use bcrypt;
use chrono::{NaiveDateTime, Utc};
Expand All @@ -11,8 +11,8 @@ use openssl::{
sign,
};
use plume_common::activity_pub::{
ap_accept_header,
inbox::{AsActor, FromId},
ap_accept_header, PUBLIC_VISIBILITY,
inbox::{AsActor, AsObject, FromId},
sign::{gen_keypair, Signer},
ActivityStream, ApSignature, Id, IntoId, PublicKey,
};
Expand Down Expand Up @@ -632,6 +632,21 @@ impl User {
Ok(CustomPerson::new(actor, ap_signature))
}

pub fn delete_activity(&self, conn: &Connection) -> Result<Delete> {
let mut del = Delete::default();

let mut tombstone = Tombstone::default();
tombstone.object_props.set_id_string(self.ap_url.clone())?;

del.delete_props.set_actor_link(Id::new(self.ap_url.clone()))?;
del.delete_props.set_object_object(tombstone)?;
del.object_props.set_id_string(format!("{}#delete", self.ap_url))?;
del.object_props.set_to_link_vec(vec![Id::new(PUBLIC_VISIBILITY)])?;
del.object_props.set_cc_link_vec(self.get_followers(conn)?.into_iter().map(|f| Id::new(f.ap_url)).collect())?;

Ok(del)
}

pub fn avatar_url(&self, conn: &Connection) -> String {
self.avatar_id
.and_then(|id| Media::get(conn, id).and_then(|m| m.url(conn)).ok())
Expand Down Expand Up @@ -832,6 +847,19 @@ impl AsActor<&PlumeRocket> for User {
}
}

impl AsObject<User, Delete, &PlumeRocket> for User {
type Error = Error;
type Output = ();

fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
if self.id == actor.id {
self.delete(&c.conn, &c.searcher).map(|_| ())
} else {
Err(Error::Unauthorized)
}
}
}

impl Signer for User {
type Error = Error;

Expand Down
4 changes: 2 additions & 2 deletions po/plume/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ msgid "Follow {}"
msgstr "اتبع"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "قم بتسجيل الدخول قصد مشاركته"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ msgstr "Писти Pluma {0}"
msgid "Follow {}"
msgstr ""

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ msgstr ""
msgid "Follow {}"
msgstr ""

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
6 changes: 4 additions & 2 deletions po/plume/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,12 @@ msgstr "Beží na Plume {0}"
msgid "Follow {}"
msgstr "Následovat {}"

msgid "Login to follow"
#, fuzzy
msgid "Log in to follow"
msgstr "Pro následování se přihlášte"

msgid "Enter your full username to follow"
#, fuzzy
msgid "Enter your full username handle to follow"
msgstr "Pro následovaní zadejte své úplné uživatelské jméno"

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ msgid "Follow {}"
msgstr "Folgen"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "Um zu boosten, musst du eingeloggt sein"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ msgstr ""
msgid "Follow {}"
msgstr ""

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/eo.po
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ msgstr ""
msgid "Follow {}"
msgstr ""

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ msgid "Follow {}"
msgstr "Seguir"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "Dejar de seguir"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ msgid "Follow {}"
msgstr "S’abonner"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "Connectez-vous pour partager"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/gl.po
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ msgid "Follow {}"
msgstr "Seguir"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "Conéctese para promover"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/hi.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ msgstr "Plume {0} का इस्तेमाल कर रहे हैं"
msgid "Follow {}"
msgstr ""

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ msgstr ""
msgid "Follow {}"
msgstr ""

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ msgid "Follow {}"
msgstr "Segui"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "Accedi per boostare"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ msgid "Follow {}"
msgstr "フォロー"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "ブーストするにはログインしてください"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
4 changes: 2 additions & 2 deletions po/plume/nb.po
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ msgid "Follow {}"
msgstr "Følg"

#, fuzzy
msgid "Login to follow"
msgid "Log in to follow"
msgstr "Logg inn"

msgid "Enter your full username to follow"
msgid "Enter your full username handle to follow"
msgstr ""

msgid "Edit your account"
Expand Down
5 changes: 3 additions & 2 deletions po/plume/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,11 @@ msgstr "Działa na Plume {0}"
msgid "Follow {}"
msgstr "Obserwuj {}"

msgid "Login to follow"
msgid "Log in to follow"
msgstr ""

msgid "Enter your full username to follow"
#, fuzzy
msgid "Enter your full username handle to follow"
msgstr "Wpisz swoją pełną nazwę użytkownika, do naśladowania"

msgid "Edit your account"
Expand Down
Loading