RadicalxChange / rxc-voice

An app for decentralized democratic governance.
https://voice.radicalxchange.org/
Other
42 stars 14 forks source link

pol.is reports not available #86

Closed alexrandaccio closed 2 years ago

alexrandaccio commented 2 years ago

Is your feature request related to a problem? Please describe. pol.is reports need to be accessed manually via the Pol.is admin portal. All pol.is conversations are currently generated on my Pol.is account, so no one can see them unless I access them myself.

Describe the solution you'd like The report urls are generated from the Pol.is admin portal. See below:

You hit the "create report url" button, which calls this api: GET https://pol.is/api/v3/reports?conversation_id=<CONVERSATION_ID>. I would like to call that api programmatically from the Voice backend server. However, the api requires authentication for the pol.is account that administers the conversation in question.

See what happens when I call that api directly from the browser:

While logged in (admin cookie present):

While not logged in (admin cookie not present):

If I can manually package the request with authentication for my pol.is admin account, I could access this api programmatically. That's the best solution I can think of at the moment, unless someone from pol.is can advise me on this. I posted a comment on the pol.is repo here

alexrandaccio commented 2 years ago

@DecimalTurn wrote a python script that works!!

I am going to open a pull request and then hand it off to him to insert his script.

alexrandaccio commented 2 years ago

Update: @DecimalTurn's script calls https://pol.is/api/v3/reports?conversation_id=<CONVERSATION_ID>, but I still need to figure out how to obtain the conversation_id from the iframe. Investigating this now, found this relevant discussion on the pol.is repo

DecimalTurn commented 2 years ago

Based on the discussion linked, seems like we should add the suggested snippet of js to the page where the iframe is located, but we would need to do an ajax call to send the value of o.conversation.conversation_id to an RxC-Voice API route that saves it.

<script>
    var polis = window.polis = window.polis || {};
    polis.on = polis.on || {};
    polis.on.init = [
      function(o) {
        if (o.status === "ok") {
          console.log("polis loaded");
          console.log(o.conversation.conversation_id);
        } else {
          console.error("error loading");
        }
      }
    ];
</script>
alexrandaccio commented 2 years ago

Got that done--PR will be ready imminently 👍