FoxxMD / context-mod

an event-based, reddit moderation bot built on top of snoowrap and written in typescript
https://contextmod.dev
MIT License
49 stars 11 forks source link

bot works, but web interface claims "bot not found"? #85

Closed wchristian closed 2 years ago

wchristian commented 2 years ago

The bot moderates fine as far as i can tell, but in the web interface, when i click on e.g. the config view, i get this:

http://localhost:8085/config?format=yaml&instance=&bot=VaushVall&subreddit=r/VaushV

image

The docker log shows nothing. Where do i even start debugging this?

FoxxMD commented 2 years ago

For fetching/saving the configuration in the dashboard CM uses auth from the account you used to login to the dashboard with, not the bot account running for the subreddit. Meaning, the reddit account you logged in with must be able to access/edit the wiki page for the subreddit you are viewing IE r/VaushV

Can you confirm that your account has full mod permissions or at least manage wiki mod permission for r/VaushV ?

wchristian commented 2 years ago

Ah, sorry, i was unclear, that happens in a lot of places in the ui. The frontpage debug log loads fine, but on the bot page the spinner goes endlessly and the network tab of chrome says there's a 404 XHR call. image

wchristian commented 2 years ago

Also the config looks like this, and i'm logged into the browser with VaushVall, and the permissions look like this.

operator:
  name: VaushVall
bots:
  - name: VaushVall
    credentials:
      reddit:
        accessToken: CCCCCCCCCCCCCCCCCC
        refreshToken: DDDDDDDDDDDDDDDDDDDDDDDDDDD
        clientId: AAAAAAAAAAAAAAAAAA
        clientSecret: BBBBBBBBBBBBBBBBBBBBB
    subreddits:
      names:
        - vaushv
web:
  credentials:
    clientId: AAAAAAAAAAAAAAAAAA
    clientSecret: BBBBBBBBBBBBBBBBBBBBB

image

FoxxMD commented 2 years ago

I have a hunch this has to do with session persistence. You have not set caching in your operator config, correct?

Can you try this:

  1. In your operator config under web add a session secret like this:
web:
  credentials:
   ...
  session:
    secret: mySecret
  1. Clear cookies/session in your browser (chrome / firefox)

  2. Restart CM and see if the problem persists

wchristian commented 2 years ago

No caching is configured. I added the section as you have it there, with the exact secret text "meepmarp", deleted cookies, restarted, reconnected, no change.

However i noticed something.

This works: http://localhost:8085/?instance=localhost%3A8095&bot=VaushVall&sub=r%2FVaushV

That page links to the bot config page, and the url looks as follows, and doesn't work.

http://localhost:8085/config?format=yaml&instance=&bot=VaushVall&subreddit=r/VaushV

If i insert the instance text from above into the url, it works.

So that value gets lost somehow.

image

wchristian commented 2 years ago

Btw, if you wanna discuss this in more realtime: Mithaldu#5818 (Tho i'm in europe and it's past midnight here already.)

FoxxMD commented 2 years ago

Ah excellent catch, that's a good lead and should help me reproduce. I will hit you up on discord if I need more info, thanks!

P.S. for now you should be able to fix this by adding this to your operator config at the top level:

api:
  friendly: local
wchristian commented 2 years ago

Can confirm that seems to fix things. :)