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

error with pinned posts #104

Closed
selyod-ka opened this issue Dec 20, 2022 · 1 comment · Fixed by #107
Closed

error with pinned posts #104

selyod-ka opened this issue Dec 20, 2022 · 1 comment · Fixed by #107
Labels
bug Something isn't working

Comments

@selyod-ka
Copy link

hey!
I just noticed an error with importing tweets, that occurs when the pinned post was pinned manually in mastodon and only later a tweet is pinned in twitter. This post then gets imported every time pleroma-bot is running.

Here are the logs:

ℹ 2022-12-20 13:02:44,191 - pleroma_bot - INFO - Processing user:       xxxxxxxxxxxxxxxxxx
ℹ 2022-12-20 13:03:02,801 - pleroma_bot - INFO - Current pinned:        xxxxxxxxxxxxxxxxxx
ℹ 2022-12-20 13:03:02,801 - pleroma_bot - INFO - Previous pinned:       None
ℹ 2022-12-20 13:03:03,931 - pleroma_bot - INFO - Post in Pleroma:       <Response [200]>
ℹ 2022-12-20 13:03:03,932 - pleroma_bot - INFO - File with previous pinned post ID not found or empty. Checking last posts for pinned post...
✖ 2022-12-20 13:03:03,932 - pleroma_bot - ERROR - Exception occurred for user, skipping... (cli.py:576)
Traceback (most recent call last):
  File "./pleroma-bot/myvenv/lib/python3.6/site-packages/pleroma_bot/cli.py", line 561, in main
    user.check_pinned(posted)
  File "./pleroma-bot/myvenv/lib/python3.6/site-packages/pleroma_bot/_utils.py", line 356, in check_pinned
    pinned_post = self.pin(id_post_to_pin)
  File "./pleroma-bot/myvenv/lib/python3.6/site-packages/pleroma_bot/_utils.py", line 630, in pin
    pin_id = self.pin_pleroma(id_post)
  File "./pleroma-bot/myvenv/lib/python3.6/site-packages/pleroma_bot/_pin.py", line 133, in pin_pleroma
    self.unpin_pleroma(pinned_file)
  File "./pleroma-bot/myvenv/lib/python3.6/site-packages/pleroma_bot/_pin.py", line 179, in unpin_pleroma
    pinned = _find_pinned(self, pinned_file)
  File "./pleroma-bot/myvenv/lib/python3.6/site-packages/pleroma_bot/_pin.py", line 200, in _find_pinned
    if post["pinned"]:
KeyError: 'pinned'

I suppose line 200 in _pin.py should read as follows:
if "pinned" in post.keys() and post["pinned"]:
At least this fixes the error in my case.

@robertoszek
Copy link
Owner

You are indeed correct!
I didn't anticipate the edge-case of a post being manually pinned alongside the ones being automatically pinned/unpinned by the bot.
Thanks for this 👍

@robertoszek robertoszek added the bug Something isn't working label Dec 20, 2022
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
Development

Successfully merging a pull request may close this issue.

2 participants