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

Post creation from Mastodon (fixes #2590) #2651

Merged
merged 4 commits into from
Jan 20, 2023
Merged

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Jan 11, 2023

This lets Mastodon users create posts on Lemmy. As they dont send a name property, we instead take the beginning of the content.

pub creator_id: PersonId,
#[builder(!default)]
Copy link
Member

Choose a reason for hiding this comment

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

These shouldn't be removed, because the database needs them. Would be better to handle the missings in the apub code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@Nutomic Nutomic marked this pull request as draft January 12, 2023 21:02
@Nutomic
Copy link
Member Author

Nutomic commented Jan 12, 2023

To be honest Im not sure if this is really a good idea. Thats why i made a thread to discuss this.

https://lemmy.ml/post/705776

@dessalines
Copy link
Member

There's one other thing I think needs to be added here, from @raphaeljolivet's suggestion:

#2590 (comment)

The first link found in the body(if there is one), could be the post link field.

@Nutomic
Copy link
Member Author

Nutomic commented Jan 13, 2023

I would rather keep it simple, the link isnt that important. Plus it could lead to unexpected behaviour if someone posts a list of multiple links, and only the first one gets emphasized by Lemmy.

Btw i cant tell why the api tests are failing, those errors seem completely unrelated.

@Nutomic Nutomic marked this pull request as ready for review January 13, 2023 21:40
@Nutomic Nutomic force-pushed the mastodon-post-creation branch 2 times, most recently from 5151066 to 371a5a3 Compare January 13, 2023 21:49
@dessalines
Copy link
Member

I'll try to run the federation tests locally and see if theres something wrong.

@dessalines
Copy link
Member

dessalines commented Jan 15, 2023

I also verified that yes this does introduce a bug in the federation tests locally, I'm trying to figure out why.

@@ -46,7 +46,7 @@ pub struct Page {
pub(crate) attributed_to: AttributedTo,
#[serde(deserialize_with = "deserialize_one_or_many")]
pub(crate) to: Vec<Url>,
pub(crate) name: String,
pub(crate) name: Option<String>,
Copy link
Member

@dessalines dessalines Jan 15, 2023

Choose a reason for hiding this comment

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

I've confirmed that this line is the one causing the test failures. Changing it back to a required string fixes them.

The error: LemmyError { message: Some("Cant receive page"), inner: Cant receive page, context: "SpanTrace" }

Copy link
Member Author

@Nutomic Nutomic Jan 15, 2023

Choose a reason for hiding this comment

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

Thats the main change in this PR. If we remove the option, then posts from Mastodon wont work. And that error message doesnt mean anything to me, can you tell where exactly its coming from?

Copy link
Member

@dessalines dessalines Jan 17, 2023

Choose a reason for hiding this comment

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

All I could get from the massive output files to /tmp/lemmy_alpha.out :

2023-01-17T18:07:02.541885Z WARN Error encountered while processing the incoming HTTP request: lemmy_server::root_span_builder: Cant receive page: Cant receive page 0: lemmy_apub::activities::community::announce::receive at crates/apub/src/activities/community/announce.rs:149

I could post the whole file but I doubt it'd be much help.

Also this one:

cant accept local object from remote instance 0: lemmy_apub::objects::comment::verify at crates/apub/src/objects/comment.rs:135 1: lemmy_apub::activities::create_or_update::comment::verify at crates/apub/src/activities/create_or_update/comment.rs:156 2: lemmy_apub::activities::community::announce::receive at crates/apub/src/activities/community/announce.rs:149

@Nutomic
Copy link
Member Author

Nutomic commented Jan 20, 2023

Turns out in those failing tests, some comments were parsed as posts which broke things. I managed to create a workaround for this, a deserialize helper function which returns an error if the field inReplyTo exists on a post. Tnat means its really a comment. This fixes the problem because in case of enum deserialization (in activity_lists.rs), serde tries each item until it hits one which doesnt throw an error.

@ryanpeach
Copy link

So what are the "instructions" for doing this?

@slrgt
Copy link

slrgt commented Jul 19, 2023

@dessalines could you post an example of how we should format posts on mastodon so they can with on Lemmy?

interoperability between the fediverse is so amazing!

@ghobs91
Copy link

ghobs91 commented Dec 2, 2023

@dessalines could you post an example of how we should format posts on mastodon so they can with on Lemmy?

interoperability between the fediverse is so amazing!

You would format it like this:

Title
Link
tag the lemmy community on mastodon

So for example, I posted this on Mastodon:

City council passed a measure calling for 30% tree canopy cover by 2035
forestforall.nyc/nyc-urban-for
@nyc@lemmy.ml

and that created this post on Lemmy: https://lemmy.ml/post/8767924

@slrgt
Copy link

slrgt commented Dec 2, 2023

@ghobs91 where would the body of the lemmy post go? Is it possible to add a body or images/videos?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants