Multi-rooms chat service.
Chat is organized into "rooms". Each room has a type and a list of players allowed to participate.
Variables available for service configuration (see config.js):
PORT
ROUTE_PREFIX
API_SECRET
- Give access to private APIsNODE_ENV
— Antything except production
means that app is running in development (debug) modeMAX_MESSAGES
- Max number of messages stored in a room (default 100)Links with DBs and other services:
REDIS_AUTH_PORT_6379_TCP_ADDR
- IP of the AuthDB redisREDIS_AUTH_PORT_6379_TCP_PORT
- Port of the AuthDB redisREDIS_CHAT_PORT_6379_TCP_ADDR
- IP of the ChatDB redisREDIS_CHAT_PORT_6379_TCP_PORT
- Port of the ChatDB redisNOTIFICATIONS_PORT_8080_TCP_ADDR
- IP of the notifications serviceNOTIFICATIONS_PORT_8080_TCP_PORT
- Port of the notifications serviceOptional link to the usermeta database containing user policies (see policies.md)
REDIS_USERMETA_PORT_6379_TCP_ADDR
- IP of the UsermetaDB redisREDIS_USERMETA_PORT_6379_TCP_PORT
- Port of the UsermetaDB redisStatsd options (used for monitoring).
STATSD_HOST
- host that runs the statsd serverSTATSD_PORT
- port to connect to statsd serverSTATSD_PREFIX
- prefix for data stored in stats (default to ganomede.chat.
)Contains the policies (banned, blocked users, chat disabled, etc)
userA:$blocked
-> user1,user2,user3
userA:$banned
-> timestamp
userA:$chatdisabled
-> "true"
"true"
indicates that the chat is disabled for this user (disabled by the user).userA:$muted
-> "true"
"true"
indicates that this user cannot chat (disabled by admin).All "room" related calls require a valid authToken, either:
API_SECRET
, in which case messages are posted as pseudo-user "$$"Create a room with a given configuration (or return the one that already exists and update its ttl).
{
"type": "triominos/v1",
"users": [ "alice", "bob" ]
}
{
"id": "triominos/v1/alice/bob",
"type": "triominos/v1",
"users": [ "alice", "bob" ],
"messages": []
}
When linked to users service, will perform ban check. Banned :username
s will receive 403 error no matter validity of a token.
Room is gonna expire 60 days after last POST.
Room's id is formed using following code:
"#{body.type}/#{body.users.sort().join('/')}"
+ Parameters
+ authToken (string, required) ... Authentication token
+ roomId (string, required) ... URL encoded Room ID
{
"id": "triominos/v1/alice/bob",
"type": "triominos/v1",
"users": [ "alice", "bob" ],
"messages": [{
"timestamp": 1429084002258,
"from": "alice",
"type": "text",
"message": "Hey bob! How are you today?"
}, {
"timestamp": 1429084002258,
"from": "bob",
"type": "text",
"message": "Hi Alice :)"
}, {
"timestamp": 1429084002258,
"from": "bob",
"type": "text",
"message": "Good thanks, let's play"
}, {
"timestamp": 1429084002258,
"from": "$$",
"type": "event",
"message": "game_started"
}]
}
No room found with given ID.
If authToken is invalid or user isn't a participant in the room, and not API_SECRET
.
+ Parameters
+ authToken (string, required) ... Authentication token
+ roomId (string, required) ... URL encoded Room ID
Append a new message to the room and updates room's TTL. If the number of messages in the room exceeds MAX_MESSAGES
, the oldest will be discarded.
{
"timestamp": 1429084016939,
"type": "txt",
"message": "Hey bob! How are you today?"
}
If authToken is invalid or user isn't a participant in the room, and not API_SECRET
.
When linked to users service, will perform ban check. Banned :username
s will receive 403 error no matter validity of a token.
No room found with given ID.
A notification will be sent to all users in the room (except the sender of the message and those that blocked him).
{
"from": "chat/v1",
"type": "message",
"data": {
"timestamp": 1429084002258,
"from": "bob",
"type": "text",
"message": "Good thanks, let's play"
}
"push": {…} // optional, will contain whatever is in `req.body.push`.
}
Join a room, append a new message and updates its TTL.
If the number of messages in the room exceeds MAX_MESSAGES
, the oldest will be discarded.
{
"type": "triominos/v1",
"users": [ "alice", "bob" ]
"timestamp": 1429084016939,
"message": "ALICE_DISCONNECTED"
}
Response codes and design notes as for the /messages entrypoint.