Compare commits
No commits in common. "f466016c014b640afe818cd4498662e4ad29ad86" and "3d504e5059a3e6f098f748ef261e2cf3a7ceefa8" have entirely different histories.
f466016c01
...
3d504e5059
3 changed files with 5 additions and 104 deletions
10
.tci
10
.tci
|
@ -1,19 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "building release binary"
|
echo "building release binary"
|
||||||
cargo build --release --all-features -j 2
|
cargo build --release --all-features
|
||||||
echo "stopping service"
|
echo "stopping service"
|
||||||
systemctl --user stop upub
|
systemctl --user stop upub
|
||||||
echo "installing new binary"
|
echo "installing new binary"
|
||||||
cp ./target/release/upub /opt/bin/upub
|
cp ./target/release/upub /opt/bin/upub
|
||||||
echo "migrating database"
|
echo "migrating database"
|
||||||
/opt/bin/upub -c /etc/upub/config.toml migrate
|
/opt/bin/upub -c /srv/tci/upub.toml --domain https://upub.alemi.dev migrate
|
||||||
echo "restarting service"
|
echo "restarting service"
|
||||||
systemctl --user start upub
|
systemctl --user start upub
|
||||||
echo "rebuilding frontend"
|
echo "rebuilding frontend"
|
||||||
cd web
|
cd web
|
||||||
CARGO_BUILD_JOBS=2 /opt/bin/trunk build --release --public-url 'https://dev.upub.social/web'
|
/opt/bin/trunk build --release --public-url 'https://upub.alemi.dev/web'
|
||||||
echo "deploying frontend"
|
echo "deploying frontend"
|
||||||
rm /srv/http/upub/dev/*
|
rm /srv/http/upub/web/*
|
||||||
mv ./dist/* /srv/http/upub/dev/
|
mv ./dist/* /srv/http/upub/web/
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
|
@ -16,9 +16,6 @@ pub use register::*;
|
||||||
mod update;
|
mod update;
|
||||||
pub use update::*;
|
pub use update::*;
|
||||||
|
|
||||||
mod nuke;
|
|
||||||
pub use nuke::*;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, clap::Subcommand)]
|
#[derive(Debug, Clone, clap::Subcommand)]
|
||||||
pub enum CliCommand {
|
pub enum CliCommand {
|
||||||
/// generate fake user, note and activity
|
/// generate fake user, note and activity
|
||||||
|
@ -93,17 +90,6 @@ pub enum CliCommand {
|
||||||
/// url for banner image of new user
|
/// url for banner image of new user
|
||||||
#[arg(long = "banner")]
|
#[arg(long = "banner")]
|
||||||
banner_url: Option<String>,
|
banner_url: Option<String>,
|
||||||
},
|
|
||||||
|
|
||||||
/// break all user relations so that instance can be shut down
|
|
||||||
Nuke {
|
|
||||||
/// unless this is set, nuke will be a dry run
|
|
||||||
#[arg(long, default_value_t = false)]
|
|
||||||
for_real: bool,
|
|
||||||
|
|
||||||
/// also send Delete activities for all local objects
|
|
||||||
#[arg(long, default_value_t = false)]
|
|
||||||
delete_objects: bool,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +108,5 @@ pub async fn run(ctx: upub::Context, command: CliCommand) -> Result<(), Box<dyn
|
||||||
Ok(update_users(ctx, days).await?),
|
Ok(update_users(ctx, days).await?),
|
||||||
CliCommand::Register { username, password, display_name, summary, avatar_url, banner_url } =>
|
CliCommand::Register { username, password, display_name, summary, avatar_url, banner_url } =>
|
||||||
Ok(register(ctx, username, password, display_name, summary, avatar_url, banner_url).await?),
|
Ok(register(ctx, username, password, display_name, summary, avatar_url, banner_url).await?),
|
||||||
CliCommand::Nuke { for_real, delete_objects } =>
|
|
||||||
Ok(nuke(ctx, for_real, delete_objects).await?),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
use apb::{ActivityMut, BaseMut, ObjectMut};
|
|
||||||
use futures::TryStreamExt;
|
|
||||||
use sea_orm::{ActiveValue::{Set, NotSet}, ColumnTrait, EntityTrait, QueryFilter, QuerySelect, SelectColumns};
|
|
||||||
|
|
||||||
|
|
||||||
pub async fn nuke(ctx: upub::Context, for_real: bool, delete_posts: bool) -> Result<(), sea_orm::DbErr> {
|
|
||||||
if !for_real {
|
|
||||||
tracing::warn!("THIS IS A DRY RUN! pass --for-real to actually nuke this instance");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut to_undo = Vec::new();
|
|
||||||
|
|
||||||
// TODO rather expensive to find all local users with a LIKE query, should add an isLocal flag
|
|
||||||
let local_users_vec = upub::model::actor::Entity::find()
|
|
||||||
.filter(upub::model::actor::Column::Id.like(format!("{}%", ctx.base())))
|
|
||||||
.select_only()
|
|
||||||
.select_column(upub::model::actor::Column::Internal)
|
|
||||||
.into_tuple::<i64>()
|
|
||||||
.all(ctx.db())
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let local_users : HashSet<i64> = HashSet::from_iter(local_users_vec);
|
|
||||||
|
|
||||||
{
|
|
||||||
let mut stream = upub::model::relation::Entity::find().stream(ctx.db()).await?;
|
|
||||||
while let Some(like) = stream.try_next().await? {
|
|
||||||
if local_users.contains(&like.follower) {
|
|
||||||
to_undo.push(like.activity);
|
|
||||||
} else if local_users.contains(&like.following) {
|
|
||||||
if let Some(accept) = like.accept {
|
|
||||||
to_undo.push(accept);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for internal in to_undo {
|
|
||||||
let Some(activity) = upub::model::activity::Entity::find_by_id(internal)
|
|
||||||
.one(ctx.db())
|
|
||||||
.await?
|
|
||||||
else {
|
|
||||||
tracing::error!("could not load activity #{internal}");
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
let Some(oid) = activity.object
|
|
||||||
else {
|
|
||||||
tracing::error!("can't undo activity without object");
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
let aid = ctx.aid(&upub::Context::new_id());
|
|
||||||
let undo_activity = apb::new()
|
|
||||||
.set_id(Some(&aid))
|
|
||||||
.set_activity_type(Some(apb::ActivityType::Undo))
|
|
||||||
.set_actor(apb::Node::link(activity.actor.clone()))
|
|
||||||
.set_object(apb::Node::link(oid))
|
|
||||||
.set_published(Some(chrono::Utc::now()));
|
|
||||||
|
|
||||||
|
|
||||||
let job = upub::model::job::ActiveModel {
|
|
||||||
internal: NotSet,
|
|
||||||
activity: Set(aid.clone()),
|
|
||||||
job_type: Set(upub::model::job::JobType::Outbound),
|
|
||||||
actor: Set(activity.actor),
|
|
||||||
target: Set(None),
|
|
||||||
published: Set(chrono::Utc::now()),
|
|
||||||
not_before: Set(chrono::Utc::now()),
|
|
||||||
attempt: Set(0),
|
|
||||||
payload: Set(Some(undo_activity)),
|
|
||||||
};
|
|
||||||
|
|
||||||
tracing::debug!("undoing {}", activity.id);
|
|
||||||
|
|
||||||
if for_real {
|
|
||||||
upub::model::job::Entity::insert(job).exec(ctx.db()).await?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
Loading…
Reference in a new issue