turt2live / matrix-dimension

An open source integration manager for matrix clients, like Element.
https://dimension.t2bot.io
GNU General Public License v3.0
431 stars 110 forks source link

Mobile app support #59

Open turt2live opened 7 years ago

turt2live commented 7 years ago

https://github.com/vector-im/riot-meta/issues/3

turt2live commented 6 years ago

The mobile apps now have integration managers, although they cannot be changed away from the hardcoded manager :(

aaronraimist commented 5 years ago

Adding this here so I can link to it later for other people who ask

People have tried and it doesn't work. Dimension is not mobile friendly and tries to use APIs that don't exist

https://matrix.to/#/!mPYrVomQESEYWWudQw:matrix.org/$154868655613786wsmXO:t2l.io?via=t2l.io&via=matrix.org&via=t2bot.io

turt2live commented 5 years ago

I'm going to consider this no longer pending upstream support: The mobile apps do support integration managers, but are obviously going to fall behind on riot-web on this front. Hoping to make Dimension mobile-capable for when https://github.com/matrix-org/matrix-doc/issues/1286 gets turned into a proposal.

Bubu commented 4 years ago

Opened this for riotX a while ago:: https://github.com/vector-im/riotX-android/issues/1497

rakshazi commented 3 years ago

Hello, element android shows dimension page, i can select widgets, but when I try to send anything, it shows something like "you didn't select any stickers, want to select now?" message

nosshar commented 2 years ago

Thanks I got some experience in web development. Spent few hours digging into problem. Project creates the database, so start with:

sqlite3 data/dimension.db
select * from dimension_scalar_tokens;
1|@kornell:<my server is here>|<here is the scalar_token value>|1|

Now take scalar token and this page going to work just fine:

https://<my server is here>/widgets/stickerpicker?widgetId=stickerpicker&scalar_token=<scalar token>

Also after sacrificing the virgin and trying several magic spells I selected a random room, and created/updated an event named "m.widgets" with the following content:

{
    "stickerpicker": {
        "content": {
            "type": "m.stickerpicker",
            "url": "https://<my server is here>/widgets/stickerpicker?widgetId=stickerpicker&scalar_token=<scalar token>",
            "name": "Stickerpicker",
            "data": {}
        },
        "sender": "@kornell:<my server is here>",
        "state_key": "stickerpicker",
        "type": "m.widget",
        "id": "stickerpicker"
    }
}

This works for Element Desktop. For Element Android (official application): 1) I can't change the integration endpoint 2) in spite of 1) I can see my stickers (also see the request in nginx access.log [it seems to be cached so called once per application start]) 3) when I click on sticker nothing happens. At all. Application closes widget pop-up, no errors, no messages in logs (nginx access.log/error.log)

nosshar commented 2 years ago

Well, another one sacrificed virgin to make it work properly on Android but here it is. I used dockerized solution, so all I had are webpacked and minimized JS. Opened (inside the container):

/home/node/matrix-dimension/build/web/main.<some hash>.js

Added a function:

function kprocess(input) {
  input.data.content.body = input.data.description;
  return input;
}

Found the following code:

console.log("[Dimension] Sending fromWidget: ",i),window.opener.postMessage(i,"*")

And replaced it with:

console.log("[Dimension] Sending fromWidget: ",i)/*KORNELL*/,window.opener.postMessage(kprocess(i),"*")

So all the problem is about missing property [Object].data.content.body in the object broadcasted via postMessage.

How I found that? I took a look at what https://github.com/maunium/stickerpicker broadcasting. Then I just compared two objects (correct one which leads to sticker to be sent and the object created by dimension). After several tries I found this exact property extesion technique working.

p.s. it's dirty to make any changes in the container itself and I probably should have contribute in repo, but I suppose it's important to have this investigation at least, it reveals the rootcause of the problem

TheTimeWalker commented 2 years ago

Thanks, though that as far as I have found out. Note the very old commit from me: https://github.com/turt2live/matrix-dimension/pull/296/commits/74ba8d795b5499c175c9f5d308a4b9711fb5d2c8

As far as I know, Element Android doesn't work well with Dimension's sticker picker widget at all. At least from my side, I get a "There was a problem authenticating" error which I unfortunately still couldn't find the root cause to it.

nosshar commented 2 years ago

Luckily something had been updated and now it works. See both of my my comments. Set up stickers for a friend (non-admin) on a private matrix node. As admin I can import stickers from telegram, enable/disable packs, other users can enble/disable active packs for themselves and use them on Desktop/Android. One restriction though - didn't find a way to provide integration manager configuration for Android (config.json overridden properties),- it leads to lacking functionality to manage active sticker packs on mobile device (but can be managed on Desktop).

nosshar commented 2 years ago

As of commit I think I just missed this change bacause started with dockerized image and didn't build the project myself on a server.

sevmonster commented 2 years ago

FYI, everything works on Android now except sticker picker authentication. Integration manager can be selected with client well-known:

{
    "m.homeserver": {
        "base_url": "https://matrix.example.com",
        "server_name": "example.com"
    },
    "m.integrations": {
        "managers": [{
            "api_url": "https://dimension.example.com/api/v1/scalar",
            "ui_url": "https://dimension.example.com/element"
        }]
    }
}

So no need to build custom Android release with updated config.json.

turbotorsten commented 2 years ago

Is there any way to get sticker picker authenticaton to work by now?

nataraj-hates-MS-for-stealing-github commented 2 years ago

FYI, everything works on Android now except sticker picker authentication. Integration manager can be selected with client well-known:

Sorry, may I ask for exact instruction? I should put this json to be availabe via https://myserver.tld/.well-known/matrix/client url?

And this will allow to use all integration services, except sticker packs in mobile version?

Do I really need to specify m.homeserver url there? Is it really needed?

turbotorsten commented 2 years ago

Sorry, may I ask for exact instruction? I should put this json to be availabe via https://myserver.tld/.well-known/matrix/client url?

Yes. All you have to change in the file sevmonster posted is replacing the example.com domains with the domains you chose in your case. Once you did that you will see that dimension is auto detected as integration manager in the app. This doesn't fix the issue that sticker picker authentification will not work. I am currently fixing that by manually applying a fix to the element-android apps source.

Ryonez commented 2 years ago

Does the authentication issue here also prevent dimension widgets from being added on mobile?