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

Titles are not generated correctly when posting from Mastodon #2686

Closed
JackFromWisconsin opened this issue Feb 1, 2023 · 8 comments · Fixed by #2709
Closed

Titles are not generated correctly when posting from Mastodon #2686

JackFromWisconsin opened this issue Feb 1, 2023 · 8 comments · Fixed by #2709
Labels
bug Something isn't working

Comments

@JackFromWisconsin
Copy link

Found a bug? Please fill out the sections below. 👍

For front end issues, use lemmy-ui

If you have problems installing Lemmy, you should post in !lemmy_support.

Issue Summary

When making a post from Mastodon, titles are not generated correctly.

Steps to Reproduce

  1. Use Mastodon
  2. mention a community (ex. @lemmy@lemmy.ml) and write your post.
  3. Look in from Lemmy
  4. Posts do not have correct title, nor does the author display a name.

Technical details

@JackFromWisconsin JackFromWisconsin added the bug Something isn't working label Feb 1, 2023
@JackFromWisconsin
Copy link
Author

Interestingly, this other post handles title generation much better: https://lemmy.ml/post/741382 . Still has some unintentional html tags visible, but closer to what we want.

@Kradyz
Copy link
Contributor

Kradyz commented Feb 1, 2023

Interestingly, this other post handles title generation much better: https://lemmy.ml/post/741382 . Still has some unintentional html tags visible, but closer to what we want.

That specific post looks like it works only because it hit the character number limit before the text reached the end of the paragraph tag (</p>).

I think that the lines() call here is expecting lines to be split by \n instead of having the syntax <p>...</p>. I am not familiar enough with the syntax in rust, but with python I would parse by splitting </p>, and then set name to the first entry from the fourth character onward.
So: name = c.split('<\p>')[0][3:]

@Kradyz
Copy link
Contributor

Kradyz commented Feb 1, 2023

I can confirm that the following modified syntax in post.rs will produce a post with the correct title:

          .and_then(|c| c.split("</p>").next().map(ToString::to_string))
      })
      .ok_or_else(|| anyhow!("Object must have name or content"))?;
    name.remove(0);
    name.remove(0);
    name.remove(0);

Here is an example post:
https://mander.xyz/post/525157

I did not submit a PR because I suspect that there is a better way to slice the string than calling remove(0) three times. Also, this change might break from_apub() function calls while fetching posts from other projects, if it is used.

EDIT: This does break other federated titles. I am experimenting with
c.replace("<p>","").replace("</p>","\n").lines()

EDIT2:

This second approach does work (https://mander.xyz/post/525174) and does not appear to break anything. I think it is reasonable, so I will submit a PR.

@informapirata
Copy link

Quel post specifico sembra funzionare solo perché ha raggiunto il limite del numero di caratteri prima che il testo raggiungesse la fine del tag di paragrafo (

).

Also from Friendica:

https://lemmy.ml/post/741998 NOK

https://lemmy.ml/post/742002 OK

@mediaformat
Copy link

mediaformat commented Mar 5, 2023

It would be great to strip the actors like the forum name from the title

https://lemmy.ml/post/787329

As an aside, this one also includes a content warning.

Lemmy ignores the CW text but interprets it as NSFW (which I guess is technically correct, but misses the point of mastodon's albeit shoehorned subject/title field)

But that's probably another can of worms

@JackFromWisconsin
Copy link
Author

JackFromWisconsin commented Mar 5, 2023 via email

@mediaformat
Copy link

@Nutomic just realized the issue is closed. I can create a new issue; does this go in lemmy or lemmy-ui?

@Nutomic
Copy link
Member

Nutomic commented Mar 6, 2023

@mediaformat You can open a new issue in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants