mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-23 02:26:36 +00:00
Instance (un)block endpoint
And hide the block button for the local instance
This commit is contained in:
parent
c1e0b6c306
commit
f1d5865a16
4 changed files with 24 additions and 9 deletions
|
@ -68,8 +68,11 @@ impl Instance {
|
|||
get!(instances);
|
||||
find_by!(instances, find_by_domain, public_domain as String);
|
||||
|
||||
pub fn block(&self) {
|
||||
unimplemented!()
|
||||
pub fn toggle_block(&self, conn: &PgConnection) {
|
||||
diesel::update(self)
|
||||
.set(instances::blocked.eq(!self.blocked))
|
||||
.get_result::<Instance>(conn)
|
||||
.expect("Couldn't block/unblock instance");
|
||||
}
|
||||
|
||||
pub fn has_admin(&self, conn: &PgConnection) -> bool {
|
||||
|
|
|
@ -65,6 +65,7 @@ fn main() {
|
|||
routes::instance::admin,
|
||||
routes::instance::admin_instances,
|
||||
routes::instance::admin_instances_paginated,
|
||||
routes::instance::toggle_block,
|
||||
routes::instance::update_settings,
|
||||
routes::instance::shared_inbox,
|
||||
routes::instance::nodeinfo,
|
||||
|
|
|
@ -154,6 +154,15 @@ fn admin_instances_paginated(admin: Admin, conn: DbConn, page: Page) -> Template
|
|||
}))
|
||||
}
|
||||
|
||||
#[get("/admin/instances/<id>/block")]
|
||||
fn toggle_block(admin: Admin, conn: DbConn, id: i32) -> Redirect {
|
||||
if let Some(inst) = Instance::get(&*conn, id) {
|
||||
inst.toggle_block(&*conn);
|
||||
}
|
||||
|
||||
Redirect::to(uri!(admin_instances))
|
||||
}
|
||||
|
||||
#[post("/inbox", data = "<data>")]
|
||||
fn shared_inbox(conn: DbConn, data: String) -> String {
|
||||
let act: serde_json::Value = serde_json::from_str(&data[..]).unwrap();
|
||||
|
|
|
@ -17,13 +17,15 @@ Administration of {{ instance.name }}
|
|||
<a href="https://{{ instance.public_domain }}">{{ instance.name }}</a>
|
||||
<small>{{ instance.public_domain }}</small>
|
||||
</p>
|
||||
<a href="/admin/instances/{{ instance.id }}/block">
|
||||
{% if instance.blocked %}
|
||||
Unblock
|
||||
{% else %}
|
||||
Block
|
||||
{% endif %}
|
||||
</a>
|
||||
{% if not instance.local %}
|
||||
<a href="/admin/instances/{{ instance.id }}/block">
|
||||
{% if instance.blocked %}
|
||||
Unblock
|
||||
{% else %}
|
||||
Block
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue