Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note wrapper (fixes #2657) #5221

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions crates/apub/src/objects/note_wrapper.rs
dessalines marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};
use activitypub_federation::{config::Data, kinds::public, traits::Object};
use chrono::{DateTime, Utc};
use lemmy_api_common::context::LemmyContext;
use lemmy_api_common::{context::LemmyContext, LemmyErrorType};
use lemmy_utils::error::{LemmyError, LemmyResult};
use serde_json::{from_value, to_value};
use url::Url;
Expand All @@ -32,12 +32,12 @@ impl Object for ApubNote {
_object_id: Url,
_context: &Data<Self::DataType>,
) -> LemmyResult<Option<Self>> {
unimplemented!()
Err(LemmyErrorType::Unknown("not implemented".to_string()).into())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at some of the others, and these all have specific FederationErrors for actions that can't be done. But its up to you there.

Also worth looking into why the unimplemented and todo passed the CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those other errors can actually occur in production. But the ones here are never be called, they are only relevant when fetching remote objects or sending objects out, neither of which is done with NoteWrapper (sending is done via PrivateMessage/Comment).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the lints not working it seems to be related to async_trait, outside of that it works fine.

}

#[tracing::instrument(skip_all)]
async fn delete(self, _context: &Data<Self::DataType>) -> LemmyResult<()> {
todo!()
Err(LemmyErrorType::Unknown("not implemented".to_string()).into())
}

async fn verify(
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Object for ApubNote {
}

async fn into_json(self, _context: &Data<Self::DataType>) -> LemmyResult<NoteWrapper> {
todo!()
Err(LemmyErrorType::Unknown("not implemented".to_string()).into())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/apub/src/objects/private_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Object for ApubPrivateMessage {
let instance = Instance::read(&mut context.pool(), recipient.instance_id).await?;
let mut kind = PrivateMessageType::Note;

// For Lemmy versions before 0.20, send private messages with old type
// Deprecated: For Lemmy versions before 0.20, send private messages with old type
if let (Some(software), Some(version)) = (instance.software, &instance.version) {
let req = VersionReq::parse("<0.20")?;
if software == "lemmy" && req.matches(&Version::parse(version)?) {
Expand Down