Adding deny unimplemented to clippy lints. (#4922)
* Adding deny unimplemented to clippy lints. - Context: #4782 * Update crates/apub/src/fetcher/site_or_community_or_user.rs Thanks, I like that better. Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Update crates/apub/src/fetcher/search.rs Co-authored-by: dullbananas <dull.bananas0@gmail.com> * Running fmt. * Adding debug_assert(false) * Removing some commands. * Format. * Remove todo. --------- Co-authored-by: dullbananas <dull.bananas0@gmail.com>
This commit is contained in:
parent
cbb37fa2f1
commit
60a7829638
17 changed files with 90 additions and 37 deletions
|
@ -86,6 +86,7 @@ suspicious = { level = "deny", priority = -1 }
|
||||||
uninlined_format_args = "allow"
|
uninlined_format_args = "allow"
|
||||||
unused_self = "deny"
|
unused_self = "deny"
|
||||||
unwrap_used = "deny"
|
unwrap_used = "deny"
|
||||||
|
unimplemented = "deny"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
lemmy_api = { version = "=0.19.5", path = "./crates/api" }
|
lemmy_api = { version = "=0.19.5", path = "./crates/api" }
|
||||||
|
|
|
@ -38,7 +38,6 @@ pub enum SiteOrCommunity {
|
||||||
Site(ApubSite),
|
Site(ApubSite),
|
||||||
Community(ApubCommunity),
|
Community(ApubCommunity),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum InstanceOrGroup {
|
pub enum InstanceOrGroup {
|
||||||
|
@ -74,12 +73,18 @@ impl Object for SiteOrCommunity {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete(self, _data: &Data<Self::DataType>) -> LemmyResult<()> {
|
async fn delete(self, data: &Data<Self::DataType>) -> LemmyResult<()> {
|
||||||
unimplemented!()
|
match self {
|
||||||
|
SiteOrCommunity::Site(i) => i.delete(data).await,
|
||||||
|
SiteOrCommunity::Community(c) => c.delete(data).await,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn into_json(self, _data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
async fn into_json(self, data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
||||||
unimplemented!()
|
Ok(match self {
|
||||||
|
SiteOrCommunity::Site(i) => InstanceOrGroup::Instance(i.into_json(data).await?),
|
||||||
|
SiteOrCommunity::Community(c) => InstanceOrGroup::Group(c.into_json(data).await?),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
|
|
@ -175,8 +175,9 @@ pub(in crate::activities) async fn receive_remove_action(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
DeletableObjects::PrivateMessage(_) => unimplemented!(),
|
// TODO these need to be implemented yet, for now, return errors
|
||||||
DeletableObjects::Person { .. } => unimplemented!(),
|
DeletableObjects::PrivateMessage(_) => Err(LemmyErrorType::CouldntFindPrivateMessage)?,
|
||||||
|
DeletableObjects::Person(_) => Err(LemmyErrorType::CouldntFindPerson)?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,9 @@ impl UndoDelete {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
DeletableObjects::PrivateMessage(_) => unimplemented!(),
|
// TODO these need to be implemented yet, for now, return errors
|
||||||
DeletableObjects::Person { .. } => unimplemented!(),
|
DeletableObjects::PrivateMessage(_) => Err(LemmyErrorType::CouldntFindPrivateMessage)?,
|
||||||
|
DeletableObjects::Person(_) => Err(LemmyErrorType::CouldntFindPerson)?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use activitypub_federation::{config::Data, traits::ActivityHandler};
|
use activitypub_federation::{config::Data, traits::ActivityHandler};
|
||||||
use lemmy_api_common::context::LemmyContext;
|
use lemmy_api_common::context::LemmyContext;
|
||||||
use lemmy_utils::error::LemmyResult;
|
use lemmy_utils::{error::LemmyResult, LemmyErrorType};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ impl InCommunity for AnnouncableActivities {
|
||||||
CollectionRemove(a) => a.community(context).await,
|
CollectionRemove(a) => a.community(context).await,
|
||||||
LockPost(a) => a.community(context).await,
|
LockPost(a) => a.community(context).await,
|
||||||
UndoLockPost(a) => a.community(context).await,
|
UndoLockPost(a) => a.community(context).await,
|
||||||
Page(_) => unimplemented!(),
|
Page(_) => Err(LemmyErrorType::CouldntFindPost.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,11 @@ impl Object for PostOrComment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn into_json(self, _data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
async fn into_json(self, data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
||||||
unimplemented!()
|
Ok(match self {
|
||||||
|
PostOrComment::Post(p) => PageOrNote::Page(Box::new(p.into_json(data).await?)),
|
||||||
|
PostOrComment::Comment(c) => PageOrNote::Note(c.into_json(data).await?),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
|
|
@ -118,8 +118,17 @@ impl Object for SearchableObjects {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn into_json(self, _data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
async fn into_json(self, data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
||||||
unimplemented!()
|
Ok(match self {
|
||||||
|
SearchableObjects::Post(p) => SearchableKinds::Page(Box::new(p.into_json(data).await?)),
|
||||||
|
SearchableObjects::Comment(c) => SearchableKinds::Note(c.into_json(data).await?),
|
||||||
|
SearchableObjects::PersonOrCommunity(pc) => {
|
||||||
|
SearchableKinds::PersonOrGroup(Box::new(match *pc {
|
||||||
|
UserOrCommunity::User(p) => PersonOrGroup::Person(p.into_json(data).await?),
|
||||||
|
UserOrCommunity::Community(c) => PersonOrGroup::Group(c.into_json(data).await?),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
fetcher::user_or_community::{PersonOrGroup, UserOrCommunity},
|
fetcher::user_or_community::{PersonOrGroup, UserOrCommunity},
|
||||||
objects::instance::ApubSite,
|
objects::{community::ApubCommunity, instance::ApubSite, person::ApubPerson},
|
||||||
protocol::objects::instance::Instance,
|
protocol::objects::instance::Instance,
|
||||||
};
|
};
|
||||||
use activitypub_federation::{
|
use activitypub_federation::{
|
||||||
|
@ -41,11 +41,14 @@ impl Object for SiteOrCommunityOrUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn read_from_id(
|
async fn read_from_id(object_id: Url, data: &Data<Self::DataType>) -> LemmyResult<Option<Self>> {
|
||||||
_object_id: Url,
|
let site = ApubSite::read_from_id(object_id.clone(), data).await?;
|
||||||
_data: &Data<Self::DataType>,
|
Ok(match site {
|
||||||
) -> LemmyResult<Option<Self>> {
|
Some(o) => Some(SiteOrCommunityOrUser::Site(o)),
|
||||||
unimplemented!();
|
None => UserOrCommunity::read_from_id(object_id, data)
|
||||||
|
.await?
|
||||||
|
.map(SiteOrCommunityOrUser::UserOrCommunity),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
@ -56,8 +59,13 @@ impl Object for SiteOrCommunityOrUser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn into_json(self, _data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
async fn into_json(self, data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
||||||
unimplemented!()
|
Ok(match self {
|
||||||
|
SiteOrCommunityOrUser::Site(p) => SiteOrPersonOrGroup::Instance(p.into_json(data).await?),
|
||||||
|
SiteOrCommunityOrUser::UserOrCommunity(p) => {
|
||||||
|
SiteOrPersonOrGroup::PersonOrGroup(p.into_json(data).await?)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
@ -75,8 +83,18 @@ impl Object for SiteOrCommunityOrUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
async fn from_json(_apub: Self::Kind, _data: &Data<Self::DataType>) -> LemmyResult<Self> {
|
async fn from_json(apub: Self::Kind, data: &Data<Self::DataType>) -> LemmyResult<Self> {
|
||||||
unimplemented!();
|
Ok(match apub {
|
||||||
|
SiteOrPersonOrGroup::Instance(a) => {
|
||||||
|
SiteOrCommunityOrUser::Site(ApubSite::from_json(a, data).await?)
|
||||||
|
}
|
||||||
|
SiteOrPersonOrGroup::PersonOrGroup(a) => SiteOrCommunityOrUser::UserOrCommunity(match a {
|
||||||
|
PersonOrGroup::Person(p) => UserOrCommunity::User(ApubPerson::from_json(p, data).await?),
|
||||||
|
PersonOrGroup::Group(g) => {
|
||||||
|
UserOrCommunity::Community(ApubCommunity::from_json(g, data).await?)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +121,9 @@ impl Actor for SiteOrCommunityOrUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inbox(&self) -> Url {
|
fn inbox(&self) -> Url {
|
||||||
unimplemented!()
|
match self {
|
||||||
|
SiteOrCommunityOrUser::Site(u) => u.inbox(),
|
||||||
|
SiteOrCommunityOrUser::UserOrCommunity(c) => c.inbox(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,11 @@ impl Object for UserOrCommunity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn into_json(self, _data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
async fn into_json(self, data: &Data<Self::DataType>) -> LemmyResult<Self::Kind> {
|
||||||
unimplemented!()
|
Ok(match self {
|
||||||
|
UserOrCommunity::User(p) => PersonOrGroup::Person(p.into_json(data).await?),
|
||||||
|
UserOrCommunity::Community(p) => PersonOrGroup::Group(p.into_json(data).await?),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
@ -115,7 +118,10 @@ impl Actor for UserOrCommunity {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inbox(&self) -> Url {
|
fn inbox(&self) -> Url {
|
||||||
unimplemented!()
|
match self {
|
||||||
|
UserOrCommunity::User(p) => p.inbox(),
|
||||||
|
UserOrCommunity::Community(p) => p.inbox(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl Object for ApubSite {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn delete(self, _data: &Data<Self::DataType>) -> LemmyResult<()> {
|
async fn delete(self, _data: &Data<Self::DataType>) -> LemmyResult<()> {
|
||||||
unimplemented!()
|
Err(LemmyErrorType::CantDeleteSite.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl Object for ApubPrivateMessage {
|
||||||
|
|
||||||
async fn delete(self, _context: &Data<Self::DataType>) -> LemmyResult<()> {
|
async fn delete(self, _context: &Data<Self::DataType>) -> LemmyResult<()> {
|
||||||
// do nothing, because pm can't be fetched over http
|
// do nothing, because pm can't be fetched over http
|
||||||
unimplemented!()
|
Err(LemmyErrorType::CouldntFindPrivateMessage.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
|
|
|
@ -193,10 +193,12 @@ impl ActivityHandler for Page {
|
||||||
type DataType = LemmyContext;
|
type DataType = LemmyContext;
|
||||||
type Error = LemmyError;
|
type Error = LemmyError;
|
||||||
fn id(&self) -> &Url {
|
fn id(&self) -> &Url {
|
||||||
unimplemented!()
|
self.id.inner()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn actor(&self) -> &Url {
|
fn actor(&self) -> &Url {
|
||||||
unimplemented!()
|
debug_assert!(false);
|
||||||
|
self.id.inner()
|
||||||
}
|
}
|
||||||
async fn verify(&self, data: &Data<Self::DataType>) -> LemmyResult<()> {
|
async fn verify(&self, data: &Data<Self::DataType>) -> LemmyResult<()> {
|
||||||
ApubPost::verify(self, self.id.inner(), data).await
|
ApubPost::verify(self, self.id.inner(), data).await
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl Crud for Comment {
|
||||||
type UpdateForm = CommentUpdateForm;
|
type UpdateForm = CommentUpdateForm;
|
||||||
type IdType = CommentId;
|
type IdType = CommentId;
|
||||||
|
|
||||||
/// This is unimplemented, use [[Comment::create]]
|
/// Use [[Comment::create]]
|
||||||
async fn create(pool: &mut DbPool<'_>, comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, comment_form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
debug_assert!(false);
|
debug_assert!(false);
|
||||||
Comment::create(pool, comment_form, None).await
|
Comment::create(pool, comment_form, None).await
|
||||||
|
|
|
@ -191,9 +191,12 @@ impl Followable for PersonFollower {
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Currently no user following
|
||||||
async fn follow_accepted(_: &mut DbPool<'_>, _: CommunityId, _: PersonId) -> Result<Self, Error> {
|
async fn follow_accepted(_: &mut DbPool<'_>, _: CommunityId, _: PersonId) -> Result<Self, Error> {
|
||||||
unimplemented!()
|
Err(Error::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn unfollow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result<usize, Error> {
|
async fn unfollow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result<usize, Error> {
|
||||||
let conn = &mut get_conn(pool).await?;
|
let conn = &mut get_conn(pool).await?;
|
||||||
diesel::delete(person_follower::table.find((form.follower_id, form.person_id)))
|
diesel::delete(person_follower::table.find((form.follower_id, form.person_id)))
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl Reportable for PrivateMessageReport {
|
||||||
_pm_id_: PrivateMessageId,
|
_pm_id_: PrivateMessageId,
|
||||||
_by_resolver_id: PersonId,
|
_by_resolver_id: PersonId,
|
||||||
) -> Result<usize, Error> {
|
) -> Result<usize, Error> {
|
||||||
unimplemented!()
|
Err(Error::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn unresolve(
|
async fn unresolve(
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Crud for Site {
|
||||||
|
|
||||||
/// Use SiteView::read_local, or Site::read_from_apub_id instead
|
/// Use SiteView::read_local, or Site::read_from_apub_id instead
|
||||||
async fn read(_pool: &mut DbPool<'_>, _site_id: SiteId) -> Result<Option<Self>, Error> {
|
async fn read(_pool: &mut DbPool<'_>, _site_id: SiteId) -> Result<Option<Self>, Error> {
|
||||||
unimplemented!()
|
Err(Error::NotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
|
||||||
|
|
|
@ -179,6 +179,7 @@ pub enum LemmyErrorType {
|
||||||
UrlWithoutDomain,
|
UrlWithoutDomain,
|
||||||
InboxTimeout,
|
InboxTimeout,
|
||||||
Unknown(String),
|
Unknown(String),
|
||||||
|
CantDeleteSite,
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_if! {
|
cfg_if! {
|
||||||
|
|
Loading…
Reference in a new issue