klausi / mastodon-twitter-sync

Synchronizes posts from Mastodon to Twitter and back
GNU General Public License v3.0
245 stars 24 forks source link

fix(post): post in chronological order #55

Closed orhun closed 1 year ago

orhun commented 1 year ago

I ran mastodon-twitter-sync for the first time and it started posting my tweets to Mastodon in reverse order.

This PR fixes this issue and processes the tweets/toots in chronological order.

giner commented 1 year ago

I'd be nice to see this merged

klausi commented 1 year ago

Thanks, fixing this behavior makes sense to me.

I think that is not exactly the right place in the code. The central function for synchronizing posts is determine_posts() which we can also test without making external API calls. Can you fix it there and add a test case?

We also need to be careful there about the synced status logic. The function is written to go backwards in time through posts and once it encounters the same post on the other platform it stops and assumes everything is synced. So maybe the easiest fix then is to reverse the order at the end of the function.

orhun commented 1 year ago

Thanks for the guidance @klausi! I updated the PR, let me know what you think 🐻

klausi commented 1 year ago

Great work @orhun , thanks a lot!

klausi commented 1 year ago

I added some more code comments about post ordering, let me know if we should improve something on that.

orhun commented 1 year ago

Looks good, thanks for the merge! 🚀