ugurdonmez / kinder-mobile

1 stars 0 forks source link

message provider #59

Closed borakrc closed 7 years ago

borakrc commented 7 years ago

db structure: /user-messages/[userId]/inbox/[randomArrayId] = { senderId = [senderUserId] message = "Hello, World!" timestamp }

/user-messages/[userId]/outbox/[randomArrayId] = { receiverId = [receiverUserId] message = "Hello, World!" timestamp }

functions: sendMessage(receiver, message) getInbox() getOutbox()

for methods getInbox() and getOutbox(), pagination can be added in the future to fasten the fetch time.

borakrc commented 7 years ago

messages can be grouped by sender/receiver in the future

borakrc commented 7 years ago

i will add read/unread information for each user of every dialog.

borakrc commented 7 years ago

we will have 2 kinds of messages.

in the future, we can merge these two message channel types by indicating participants in an array (two participants for private, more for a group). but that's too much work for now.

structure of user-user messages: /user-messages/[this.userId]/[interactingUserId] = [ message = "Hello, World!" timestamp type = "incoming" || "outgoing" ]

/user-messages/[this.userId]/[interactingUserId]/isUnread = true || false

I am aware we keep two copies of the message. One at the transmitter user, one at the receiver user. This makes the implementation easier and faster. Besides, deleting a message or the whole conversation at one end is easier. Also we can keep isRead status that way.

if messages are not already ordered by timestamp when we fetch it, we should sort in the fetch query.

in the future, we can use enum for messageType.

borakrc commented 7 years ago

structure of class wall messages:

/classes/{{classId}}/wall = [ message = "Hello, World!" timestamp sender = [senderUserId] ]

structure below keeps list of users that read the wall. we can't keep unread users, because wall is also available to the admins and new parents can always join. /classes/{{classId}}/wallRead = { {{userId}} = true }

borakrc commented 7 years ago

I am having problems accessing the profile picture urls of teachers and parents. I will find a way to get profile pic urls first.

borakrc commented 7 years ago

at the moment, there is no way to distinguish between messages and isUnread: true because they're under the same array. seperate them. after that, refactor message front end to show unread message warnings.