status-im / status-protocol-go

Status Protocol implementation in Go
Mozilla Public License 2.0
0 stars 1 forks source link

Link Messages to Chats #62

Closed adambabik closed 4 years ago

adambabik commented 5 years ago

As a developer, I would like to have incoming messages linked to an instance of Chat so that I can match incoming messages to chats and vice versa.

Problem

v1.Message has a property ChatID. Messenger exposes methods to manage Chats. The problem is that there is no direct connection between one and another.

ChatID from v1.Message is a ChatID from the sender perspective so it cannot really be used by the receiver. There must be another way of matching a message to a chat. It may happen that there is no chat for an incoming message. In such a case, Chat instance should be automatically created.

We need to establish rules how a message is matched against a chat.

Acceptance criteria

cc @cammellos @oskarth

cammellos commented 5 years ago

Not sure I fully understand, but currently there are already rules to match a message against a chat, these are tight to the channel we receive the message on, mainly for security reasons:

The message is coming from a filter installed by a public chat

The message is coming through a private filter (negotiated/discovery)

We look at a field {:content {:chat-id "x"}}, let's call this self-reported-chat-id, and message-type.

Is that what you mean or I misunderstood?

adambabik commented 5 years ago

@cammellos this issue is about collecting these rules and implement them in status-protocol-go as well as describe in the specs repo. I know we have them because chats work but it's hidden knowledge in status-react.

Is that what you mean or I misunderstood?

That's exactly what I needed :) In the console-client, I implemented recently (still in progress) matching of messages of type :user-message. I will continue with :group-user-message but needed confirmation.

And as mentioned above, I believe this implementation should live here because this lib already implement chats. Do you agree?

Also, we want this to be a part of the protocol specs, unless you already did it at some point.

cammellos commented 5 years ago

And as mentioned above, I believe this implementation should live here because this lib already implement chats. Do you agree? Yes, I agree.

Also, we want this to be a part of the protocol specs, unless you already did it at some point.

I don't think is documented anywhere, good point

oskarth commented 5 years ago

Agree on documenting these hidden behaviours. Do either of you want to issue a PR to the specs repo?

adambabik commented 4 years ago

@oskarth The only thing that's left is private groups. Other type of chats are covered in https://github.com/status-im/status-protocol-go/pull/66.

adambabik commented 4 years ago

@cammellos Can you point me to the code that creates a private group chat ID?

EDIT: I found that it's uuid + admin-public-key-hex. Is that correct? EDIT: I found confirmation in our spec: https://github.com/status-im/specs/blob/master/status-group-chats-spec.md#chat-id

adambabik commented 4 years ago

This is done https://github.com/status-im/status-protocol-go/blob/v0.4.2/messenger.go#L1000-L1054.