tinode / chat

Instant messaging platform. Backend in Go. Clients: Swift iOS, Java Android, JS webapp, scriptable command line; chatbots
GNU General Public License v3.0
11.94k stars 1.87k forks source link

workflow question #164

Closed sad1y closed 5 years ago

sad1y commented 5 years ago

Subject of the issue

My ultimate goal - creating group topics and invite group of people with read access only, when appropriate circumstances happens i need to give them write access permission. so, for now i stuck with invite user into topic

client logs (gRpc):

{ "hi": { "id": "2dc8a913", "userAgent": "tinode-dotnet-core-client", "ver": "0.15.6-rc5", "deviceId": "2dc8a913", "lang": "EN" } }
{ "ctrl": { "id": "2dc8a913", "code": 201, "text": "created", "params": { "ver": "IjAuMTUi", "build": "Im15c3FsOnYwLjE1LjYi" } } }
connected successfully!
ver: "0.15", build: "mysql:v0.15.6"
{ "login": { "id": "2dc8a914", "scheme": "basic", "secret": "em90aDpxd2VydHkx" } }
{ "ctrl": { "id": "2dc8a914", "code": 200, "text": "ok", "params": { "authlvl": "ImF1dGgi", "token": "Imp2WmZxNWhybWNqWk9jaGJGQUFCQUFFQUJvRUlVNHJ2L1ZCTTI3RTBpdkdmK1N0NWQrRVQxUkZPM2UzcElocmdOMFE9Ig==", "expires": "IjIwMTgtMTAtMThUMDc6NDQ6MjUuMzAyWiI=", "user": "InVzcmp2WmZxNWhybWNnIg==" } } }
{ "sub": { "id": "2dc8a915", "topic": "me" } }
{ "ctrl": { "id": "2dc8a915", "topic": "me", "code": 200, "text": "ok", "params": { "acs": "eyJ3YW50IjoiSlAiLCJnaXZlbiI6IkpQIiwibW9kZSI6IkpQIn0=" } } }
logged as "usrjvZfq5hrmcg"
{ "get": { "id": "2dc8a916", "topic": "me", "query": { "what": "sub" } } }
[False] [{ "want": "JRWPASDO", "given": "JRWPASDO" }] grpF4CZiSWRnWY, 
[False] [{ "want": "JRWPASDO", "given": "JRWPASDO" }] grpipBmTk2yGXQ, 
[False] [{ "want": "JRWPASDO", "given": "JRWPASDO" }] grpMlmytvcwD3o, 
[False] [{ "want": "JRWPASDO", "given": "JRWPASDO" }] grpXEd8lucFGIw, zoth_topic
[False] [{ "want": "JRWPASDO", "given": "JRWPASDO" }] grpY6x5cZ3STdc, zoth_topic
[False] [{ "want": "JRWPASDO", "given": "JRWPASDO" }] grpAZ6s2_t7hHs, zoth_topic
{ "set": { "id": "2dc8a917", "topic": "grpAZ6s2_t7hHs", "query": { "sub": { "userId": "usrGSjCKKgfjsY", "mode": "JRWS" } } } }
{ "ctrl": { "id": "2dc8a917", "topic": "grpAZ6s2_t7hHs", "code": 403, "text": "permission denied" } }

as you can see i send {set} with {sub} to topic which is owned by me and for some reasons server respond me with 403 error. What i doing wrong?

or-else commented 5 years ago

Can you show the server log too?

Does user usrGSjCKKgfjsY exist? What's the defacs of this user?

sad1y commented 5 years ago

i ran server in docker container and attached to it by docker attach --sig-proxy=true but unfortunately stdout is empty. I also searched for any logging options but didnt find anything. could you guide me how to do it properly? thanks

sad1y commented 5 years ago

and yes this user exists (builtin alice)

or-else commented 5 years ago

To see the logs in the running container do this:

docker exec -it name-of-the-running-container /bin/bash

Then see the log with tail -50 /var/log/tinode.log

sad1y commented 5 years ago

@or-else it works like a charm, thank you. the problem is that i didnt subscribe to topic which i want to change, i didnt get it from the start but if i get it right, every single action with topic required subscription, right? if so is there any more convenient way to subscribe to every topic that i have (when i login in from the other device, for example)? or just send request for each of them?

or-else commented 5 years ago

every single action with topic required subscription, right?

every action except:

or just send request for each of them?

Yes. The topic must be loaded into memory before anything can be done with it. The topic is loaded into memory on {sub}.

Take a look a root-user branch. It has a new feature: it allows a root user to to issue a gRPC request on behalf of another user. In your case instead of {sub user1} to topic then {set user2} you can directly issue a {sub user2}.

Don't forget to issue {leave} when you are done with the topic.

or-else commented 5 years ago

BTW, if you need to create the initial setup for a lot of users then you can modify init-db to pre-create the database with the users, topics, and subscriptions. Afterwards, as new users join your system, you only need to create the topics and subscriptions for each new user individually. It won't matter if you {sub} first for each user. You are unlikely to have a million new users every day.

sad1y commented 5 years ago

You are awesome! Thanks a lot