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

Publicize: add Fediverse meta tag on posts when available #38198

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Jul 4, 2024

Proposed changes:

See https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

If we have an existing Mastodon connection on the site, let's add it as meta tag on each post.

Note

This first iteration picks up the first available Mastodon connection. I think we should aim to make sure we pick the one that's assigned to the post author. @automattic/jetpack-reach Do you have any ideas on how I could do that?

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

  • peLCyI-nZ-p2

Does this pull request change what data or activity we track or use?

  • No

Testing instructions:

  • Go to Jetpack > Settings > Sharing
  • Enable Jetpack Social, and connect your site to a test Mastodon account.
  • Go to Posts > Add New
  • Write a post and publish it. In the post sidebar, ensure the post is shared to Mastodon.
  • Check the source of the post on the frontend: you should see this: <meta name="fediverse:creator" content="@[email protected]" />

@jeherve jeherve added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Feature] Publicize Now Jetpack Social, auto-sharing [Status] Proposal [Pri] Normal [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin labels Jul 4, 2024
@jeherve jeherve requested a review from a team July 4, 2024 13:41
@jeherve jeherve self-assigned this Jul 4, 2024
@jeherve jeherve force-pushed the add/fediverse-tag-social branch from adc154d to 03de30c Compare July 4, 2024 13:42
See https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

If we have an existing Mastodon connection on the site, let's add it as meta tag on each post.
Copy link
Contributor

github-actions bot commented Jul 4, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for August 6, 2024 (scheduled code freeze on August 5, 2024).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.


Social plugin:

  • Next scheduled release: August 6, 2024.
  • Scheduled code freeze: July 29, 2024.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

github-actions bot commented Jul 4, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/fediverse-tag-social branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack add/fediverse-tag-social
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@pablinos
Copy link
Contributor

pablinos commented Jul 5, 2024

This looks good. Thanks for working on it @jeherve!

It's an edge case, but what should we do when there is more than one Mastodon connection? This change will pick the first, but that could be a shared connection from another author on the site. We could check that the connection is owned by the author of the post, but they might not want to promote the post on that account.

Perhaps we live with that for now, as it will be a rare occurrence, and we can tackle it when we look at meta tags in general? We currently have similar problems with picking OpenGraph images and conflicts with SEO plugins.

@jeherve
Copy link
Member Author

jeherve commented Jul 5, 2024

what should we do when there is more than one Mastodon connection? This change will pick the first, but that could be a shared connection from another author on the site. We could check that the connection is owned by the author of the post, but they might not want to promote the post on that account.

Yes, this was my concern as well, as per my question in the PR description.

Perhaps we live with that for now, as it will be a rare occurrence

I'd be okay with that but wanted y'all to make the call.

we can tackle it when we look at meta tags in general? We currently have similar problems with picking OpenGraph images and conflicts with SEO plugins.

Is that something that's on the Reach roadmap?

@pfefferle
Copy link
Member

pfefferle commented Jul 5, 2024

It's an edge case, but what should we do when there is more than one Mastodon connection?

I can't say something about the shared connection case (I have not yet looked into the code), but it is possible to add multiple accounts. For now Mastodon will pick the first one, but they think about supporting multiple in the future.

If multiple tags are present on the page, the first one will be displayed, but we may add support for showing multiple authors in the future.

@spsiddarthan
Copy link
Contributor

Hi @jeherve!

I just found the time to review this, my apologies for jumping in on this late.

In the proposed change, we are picking the first connection that's either owned by the author or a connection that's shared.
This line determines whether the connection is shared. We could choose to not add the tags only for non-shared connection for now.

In a subsequent iteration, even if a connection is shared, we could add a flag to determine whether a shared connection was created by the author. If yes, we could add the tags in that case as well. This is the line fbhepr%2Skers%2Sjcpbz%2Sjc%2Qpbagrag%2Snqzva%2Qcyhtvaf%2Schoyvpvmr%2Schoyvpvmr%2Qjcpbz.cuc%3Se%3Q8681o875%26sv%3Qtrg_nyy_pbaarpgvbaf_sbe_oybt_vq%232134-og that populates the connection data. The @reach-team can pick it up, I am not sure of timelines yet, but we can do it within a couple of sprints.

Screenshot 2024-07-12 at 7 29 51 PM

No, nothing specific towards it at the moment.

jeherve added 2 commits July 12, 2024 20:28
1. We now keep all existing Mastodon connections for a post, as long as that post was published to that connection. If you've opted not to share that post to Mastodon, we do not keep that connection.
2. We keep both your own connections as well as any other global connections on the site.
3. We then sort through those connections:
    * We prioritize your own connections, and pick the first of them,
    * If you, the author, haven't published that specific post to a Mastodon connection, we look for global Mastodon connections. If there are some, we pick the first.

See discussion here:
#38198 (comment)
@jeherve
Copy link
Member Author

jeherve commented Jul 12, 2024

Thanks for the feedback!

I just pushed 44cef09 to add some extra logic:

  1. We now keep all existing Mastodon connections for a post, as long as that post was published to that connection. If you (the post author) have opted not to share that post to Mastodon, we do not keep that connection.
  2. We keep both your own connections as well as any other global connections on the site.
  3. We then sort through those connections:
    • We prioritize your own connections, and pick the first of them,
    • If you haven't published that specific post to a Mastodon connection, we look for global Mastodon connections. If there are some, we pick the first.

Would that logic align with what you had in mind?

Copy link
Contributor

@spsiddarthan spsiddarthan left a comment

Choose a reason for hiding this comment

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

This looks good, @jeherve! We can merge it.

I tested it on both shared and non-shared connections.

@jeherve jeherve merged commit fe17eb1 into trunk Jul 15, 2024
58 checks passed
@jeherve jeherve deleted the add/fediverse-tag-social branch July 15, 2024 07:27
matticbot pushed a commit to Automattic/jetpack-publicize that referenced this pull request Jul 15, 2024
* Publicize: add Fediverse meta tag on posts when available

See https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

If we have an existing Mastodon connection on the site, let's add it as meta tag on each post.

* Improve logic to support global connections.

1. We now keep all existing Mastodon connections for a post, as long as that post was published to that connection. If you've opted not to share that post to Mastodon, we do not keep that connection.
2. We keep both your own connections as well as any other global connections on the site.
3. We then sort through those connections:
    * We prioritize your own connections, and pick the first of them,
    * If you, the author, haven't published that specific post to a Mastodon connection, we look for global Mastodon connections. If there are some, we pick the first.

See discussion here:
Automattic/jetpack#38198 (comment)

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9935380055

Upstream-Ref: Automattic/jetpack@fe17eb1
matticbot pushed a commit to Automattic/jetpack-storybook that referenced this pull request Jul 15, 2024
* Publicize: add Fediverse meta tag on posts when available

See https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

If we have an existing Mastodon connection on the site, let's add it as meta tag on each post.

* Improve logic to support global connections.

1. We now keep all existing Mastodon connections for a post, as long as that post was published to that connection. If you've opted not to share that post to Mastodon, we do not keep that connection.
2. We keep both your own connections as well as any other global connections on the site.
3. We then sort through those connections:
    * We prioritize your own connections, and pick the first of them,
    * If you, the author, haven't published that specific post to a Mastodon connection, we look for global Mastodon connections. If there are some, we pick the first.

See discussion here:
Automattic/jetpack#38198 (comment)

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9935380055

Upstream-Ref: Automattic/jetpack@fe17eb1
matticbot pushed a commit to Automattic/jetpack-social-plugin that referenced this pull request Jul 15, 2024
* Publicize: add Fediverse meta tag on posts when available

See https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

If we have an existing Mastodon connection on the site, let's add it as meta tag on each post.

* Improve logic to support global connections.

1. We now keep all existing Mastodon connections for a post, as long as that post was published to that connection. If you've opted not to share that post to Mastodon, we do not keep that connection.
2. We keep both your own connections as well as any other global connections on the site.
3. We then sort through those connections:
    * We prioritize your own connections, and pick the first of them,
    * If you, the author, haven't published that specific post to a Mastodon connection, we look for global Mastodon connections. If there are some, we pick the first.

See discussion here:
Automattic/jetpack#38198 (comment)

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9935380055

Upstream-Ref: Automattic/jetpack@fe17eb1
matticbot pushed a commit to Automattic/jetpack-production that referenced this pull request Jul 15, 2024
* Publicize: add Fediverse meta tag on posts when available

See https://blog.joinmastodon.org/2024/07/highlighting-journalism-on-mastodon/

If we have an existing Mastodon connection on the site, let's add it as meta tag on each post.

* Improve logic to support global connections.

1. We now keep all existing Mastodon connections for a post, as long as that post was published to that connection. If you've opted not to share that post to Mastodon, we do not keep that connection.
2. We keep both your own connections as well as any other global connections on the site.
3. We then sort through those connections:
    * We prioritize your own connections, and pick the first of them,
    * If you, the author, haven't published that specific post to a Mastodon connection, we look for global Mastodon connections. If there are some, we pick the first.

See discussion here:
Automattic/jetpack#38198 (comment)

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9935380055

Upstream-Ref: Automattic/jetpack@fe17eb1
spsiddarthan added a commit that referenced this pull request Jul 30, 2024
jeherve added a commit that referenced this pull request Aug 9, 2024
This is a follow-up to #38198, which was partially reverted in #38612.
It's an alternative to #38565, to ensure better compatibility with WordPress.com Simple.

1. It takes into account the ActivityPub plugin, and ensure we're not adding a tag when the ActivityPub plugin already adds one.
2. It takes into account that on WordPress.com Simple, `get_services()` may return a `Keyring_Access_Token` object instead of an array.
3. It adds the 2 necessary methods directly to the `functions.opengraph.php` file, since we know it is loaded on the frontend on WordPress.com Simple (see conversation here to find out more: #38565 (comment) )
jeherve added a commit that referenced this pull request Aug 12, 2024
…38809)

* Publicize: add Fediverse creator meta tag from Mastodon connection

This is a follow-up to #38198, which was partially reverted in #38612.
It's an alternative to #38565, to ensure better compatibility with WordPress.com Simple.

1. It takes into account the ActivityPub plugin, and ensure we're not adding a tag when the ActivityPub plugin already adds one.
2. It takes into account that on WordPress.com Simple, `get_services()` may return a `Keyring_Access_Token` object instead of an array.
3. It adds the 2 necessary methods directly to the `functions.opengraph.php` file, since we know it is loaded on the frontend on WordPress.com Simple (see conversation here to find out more: #38565 (comment) )

* Add missing since parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Publicize Now Jetpack Social, auto-sharing [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin [Pri] Normal [Status] Proposal [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants