Remove old lints

This commit is contained in:
Riley Apeldoorn 2024-05-04 19:48:38 +02:00
parent 34e665154d
commit d1b08f1b07
3 changed files with 25 additions and 45 deletions

View file

@ -1,6 +0,0 @@
disallowed-methods = [
{ path = "puppy::context", reason = "for external use only (interferes with `test_context`)" }
]
disallowed-types = [
{ path = "store::Result", reason = "generates confusing docs; parameterize puppy::Result by puppy::StoreError instead." }
]

View file

@ -2,19 +2,11 @@
//! you should take a look at [`fetch`].
// Working with result types is such a bitch without these.
#![feature(iterator_try_collect, try_blocks, once_cell_try)]
// Cause an error if someone tries to call [`context`] from within this crate. If we need one,
// it must be passed in as a parameter. Getting a hold of a context is not our job. We need to
// forbid internal code from calling the function because it is stateful, and that can cause
// spooky action at a distance within tests.
//
// Ideally this would be enforced by the compiler, and we *can* enforce it at the type level,
// but that would make every type signature ever 100x more complicated, so we're not doing it.
#![deny(clippy::disallowed_methods, clippy::disallowed_types)]
#![feature(iterator_try_collect, try_blocks, once_cell_try, box_into_inner)]
use std::hint::unreachable_unchecked;
use actor::{get_signing_key, Actor};
use actor::get_signing_key;
pub use context::Context;
#[cfg(test)]
pub use context::test_context;
@ -33,7 +25,7 @@ pub mod post;
mod interact;
use derive_more::{From, Display};
use tracing::{error, instrument, warn};
use tracing::{instrument, warn};
/// Retrieve an ActivityPub object from the database.
///
@ -152,29 +144,27 @@ pub mod actor {
}
/// Register an actor from another server.
pub fn create_remote(cx: &Context, object: object::Actor) -> Result<Actor> {
pub fn create_remote(tx: &Transaction<'_>, object: object::Actor) -> Result<Actor> {
let key = Key::gen();
cx.run(|tx| {
tx.add_alias(key, Id(object.id.clone()))?;
tx.add_mixin(key, Channel { inbox: object.inbox })?;
tx.add_mixin(key, Object {
kind: ObjectKind::Actor,
id: Id(object.id),
local: false,
})?;
tx.add_mixin(key, Profile {
post_count: 0,
account_name: Username(object.account_name),
display_name: object.display_name,
about_string: None,
about_fields: Vec::new(),
})?;
tx.add_mixin(key, PublicKey {
key_id: object.public_key.id,
key_pem: object.public_key.inner,
})?;
Ok(Actor { key })
})
tx.add_alias(key, Id(object.id.clone()))?;
tx.add_mixin(key, Channel { inbox: object.inbox })?;
tx.add_mixin(key, Object {
kind: ObjectKind::Actor,
id: Id(object.id),
local: false,
})?;
tx.add_mixin(key, Profile {
post_count: 0,
account_name: Username(object.account_name),
display_name: object.display_name,
about_string: None,
about_fields: Vec::new(),
})?;
tx.add_mixin(key, PublicKey {
key_id: object.public_key.id,
key_pem: object.public_key.inner,
})?;
Ok(Actor { key })
}
/// Add properties related to local ActivityPub actors to a vertex.
@ -345,7 +335,7 @@ pub async fn ingest(cx: &Context, auth: Key, activity: &Activity) -> Result<()>
let object = Object::from_json(json).unwrap();
match object {
Object::Activity(a) => interpret(&cx, a)?,
Object::Actor(a) => actor::create_remote(cx, a).map(void)?,
Object::Actor(a) => cx.run(|tx| actor::create_remote(tx, a).map(void))?,
Object::Note(a) => post::create_post_from_note(cx, a).map(void)?,
_ => todo!(),
}
@ -355,7 +345,3 @@ pub async fn ingest(cx: &Context, auth: Key, activity: &Activity) -> Result<()>
/// Discard the argument.
fn void<T>(_: T) -> () {}
pub mod remote {
//! Bridging the gap between other servers and us.
}

View file

@ -13,7 +13,7 @@
//! There are three interfaces to the store: the read-only [`Store`], the write-only [`Batch`] and the [`Transaction`],
//! which allows both reads and writes.
use std::{cell::RefCell, path::Path, sync::Arc};
use std::{cell::RefCell, future::Future, path::Path, sync::Arc};
use derive_more::{From, Display};
use rocksdb::{Options, TransactionDBOptions, WriteBatchWithTransaction};