We are thinking of moving from Pusher to Firebase. We are worried about how Pusherโs feeds will be featured in Firebase.
At Pusher, we have a channel for each user. Thus, the user may be in the channel user-1 , the other may be in the channel user-2 .
Then our server / server will send a message to both of these users via Pusher.trigger(message, ['user-1', 'user-2']) .
I think this is usually done as follows:
{ web_page_1: { user_1: { messages: [{}, {}, ..], }, user_2: { messages: [{}, {}, ..], }, ... }, web_page_2: { user_2: { messages: [{}, {}, ..], }, user_3: { messages: [{}, {}, ..], } }, .... }
Here's the problem: user 1 and user 2 for the same page can have many common posts. Is there a way to reduce this duplication, as these messages can become quite large, sending and storing them per user can become expensive. Also, user 1 should not read messages from user 2.
It would be nice to do something like this:
{ web_page_1: { message_1: { user_ids: [1,2,3] content: {}, }, message_2: { recipient_ids: [3,4,5] content: {}, } ... }, web_page_2: { message_1: { user_ids: [1,2,3] content: {}, }, message_2: { user_ids: [3,4,5] content: {}, } }, .... }
But then, how will the security policy be applied, so that the message can only be read by the user_id specified in it.
Any pointers would be really appreciated.