dshanske / bridgy-publish

Bridgy for WordPress ( Functionality now in Syndication Links Plugin. This is being deprecated)
https://wordpress.org/plugins/bridgy-publish
8 stars 6 forks source link

p-bridgy-twitter-content (aka excerpt) not rendered consistently? #49

Closed snarfed closed 6 years ago

snarfed commented 6 years ago

(moved here from https://github.com/snarfed/bridgy/issues/527#issuecomment-346536517)

@jackysee:

However I still found my publish problematic, the p-bridgy-twitter-content is not captured when using wordpress bridgy publish. I guess it's the plugin problem. ... It's version 1.3.3.

A sample: Post: https://jacky.seezone.net/2017/11/23/9304/ Syndicated to tweet: https://twitter.com/jackysee/status/933571631431274497 bridgy log: https://brid.gy/log?start_time=1511415796&key=aglzfmJyaWQtZ3lyUQsSDVB1Ymxpc2hlZFBhZ2UiKmh0dHBzOi8vamFja3kuc2Vlem9uZS5uZXQvMjAxNy8xMS8yMy85MzA0LwwLEgdQdWJsaXNoGICAgICAgIAKDA

The plugin unticked 'Set twitter from post excerpt' The theme would generate an html for brid.gy to consume:

<div class="p-bridgy-twitter-content" style="display:none">//不幸看到100毛那個「從家用解釋不同主義」系列 https://medium.com/@_.__/%E6%9C%89%E6%99%82%E5%80%99%E5%AF%A7%E9%A1%98%E4%BD%A0%E7%9B%B4%E6%8E%A5%E6%8A%84-dcfa1ed8bbc</div>

If I preview the post in brid.gy, it can consume the p-bridgy-twitter-content. The corresponding log: https://brid.gy/log?start_time=1511416239&key=aglzfmJyaWQtZ3lyUQsSDVB1Ymxpc2hlZFBhZ2UiKmh0dHBzOi8vamFja3kuc2Vlem9uZS5uZXQvMjAxNy8xMS8yMy85MzA0LwwLEgdQdWJsaXNoGICAgICAgIAKDA

@dshanske:

@snarfed According to the log, it is captured. Ideas?

true! in the preview...but not in the publish. the post currently at https://jacky.seezone.net/2017/11/23/9304/ has p-bridgy-twitter-content, and the preview log does show it in parsed mf2...but the publish log (4m earlier) does not, which implies that it wasn't there when the publish happened.

looks like the publish happened immediately, via webmention. maybe p-bridgy-twitter-content gets added later, async, and the publish webmention beat it? or maybe the publish saw an earlier cached version?

snarfed commented 6 years ago

(@jackysee mentioned the same thing in https://github.com/snarfed/bridgy/issues/527#issuecomment-346642904)

jackysee commented 6 years ago

One of the hint is that the post is shown as 'uncategorized', while the post actually is categorized as 'weblinks'. So it may be that bridgy is somehow reading a work-in-progress post?

jackysee commented 6 years ago

Following the lead on the 'uncategorized', I found that when my save the post through the rest api, with status='publish' directly, the post at the moment of save_post hook doesn't have category (hence uncategorized) or post format, which I used in theme to render the p-bridgy-twitter-content. Therefore, at the moment when bridgy send webmention, the p-bridgy-twitter-content is not there, and thus use the content body directly as the tweet content.

However, even though the post is not saved completely at that moment, it is afterwards, with correct category and post format, so subsequent manual ping using bridgy itself has no problem.

A way to work around it is to send two rest requests instead, one save as draft, and then one save as publish.

So this case only happen when using the rest api and publish immediately, while I don't know if it's a bug for wordpress or something I missed about the rest api.

dshanske commented 6 years ago

I used to solve this by having the publish action occur a few seconds later. But it was suggested I remove this so it would happen immediately.

dshanske commented 6 years ago

Since I am planning on deprecating the plugin, marking these closed.