hatkidchan / mastoposter

Mastodon to [anything] reposter. Anything being {Telegram, Discord} for now.
GNU General Public License v3.0
28 stars 3 forks source link

Add Pleroma support #3

Closed hatkidchan closed 2 years ago

hatkidchan commented 2 years ago

For now it's not really possible to get posts from Pleroma instances. Though, it's kinda against "Mastodon" part of mastoposter, it still should be considered to be done.

For now all I know is that:

TBD:

hatkidchan commented 2 years ago

Sending token both as access_token query parameter and Authorization: Bearer XXX does nothing, /api/v1/streaming still fails with Unauthorized status code. That's probably because default token doesn't have permissions to work with streaming.

  # List streams.
  def get_topic(
        "list",
        %User{id: user_id} = user,
        %Token{user_id: user_id} = oauth_token,
        %{"list" => id}
      ) do
    cond do
      OAuthScopesPlug.filter_descendants(["read", "read:lists"], oauth_token.scopes) == [] ->
        {:error, :unauthorized}

      Pleroma.List.get(id, user) ->
        {:ok, "list:" <> to_string(id)}

      true ->
        {:error, :bad_topic}
    end
  end

I know nothing about Pleroma API nor I have any experience in Elixir. If anyone does, please, explain to me how should I authenticate myself to work with streaming API.

hatkidchan commented 2 years ago

Ok turns out I was just dumb and forgot to change instance to Pleroma one :skull:

Anyways, it still fails because Pleroma (or at least EMR) doesn't return the "discoverable" field in the "account". I'll just make it fall back to False for the time being. Not like it's important for the crossposter

hatkidchan commented 2 years ago

@cmd410 pls confirm that Pleroma works

cmd410 commented 2 years ago

Nope, pleroma doesn't work apparently. Literally nothing happens

hatkidchan commented 2 years ago

@cmd410: Literally nothing happens

https://user-images.githubusercontent.com/35804000/188282811-32428034-7290-4ed6-b72b-b36d55235e36.mp4

cmd410 commented 2 years ago

Hmmm, dunno, i've set instance, token, user id, bot token, and channel, launched it, and it just hangs doing nothing

hatkidchan commented 2 years ago

If you're on latest commit, try adding this into mastoposter/__init__.py near line 18:

    async for status in source(**kwargs): # <= this is line 18
        print(f"{user=} {status.account.id=} {status.visibility=}")
        if status.account.id != user:
            continue
hatkidchan commented 2 years ago

Was using it on Pleroma for a while already, seems to be working more or less fine. Closing it now. In case there's any issues with Pleroma, please, create separate one