Skip to content

Instantly share code, notes, and snippets.

@jcolebrand
Last active December 11, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcolebrand/4521772 to your computer and use it in GitHub Desktop.
Save jcolebrand/4521772 to your computer and use it in GitHub Desktop.
/* COLE!! DO NOT FORGET ABOUT BOT ELEMENTS!! ~~~~ cole */
/* for every x, xBy field pair (eg: deleted/deletedBy), should consider replacing with an object and use falsey-nulls for non-case
* have the object be a "by" which consists of the date and whatever is in the by field, currently a user-id and user-name
*/
chat comments:
{
id: long,
room: int,
author: Object, /* author-short */
timestamp: Date,
body: String,
html: String,
classes: String, /* holds any specific rendering classes needed */
oneboxed: String, /* indicates that the post was oneboxed, and indicates which onebox was used, for display purposes */
renderVersion: int, /* updated with the version of the last renderer to turn the current body into the current html */
replyTo: int, /* another post id */
history: Array,
edited: Date, /* nonfalsey means edited */
editedBy: Object, /* author-short, last edit author */
deleted: Date, /* nonfalsey means deleted */
deletedBy: Object, /* author-short */
pinned: Date, /* nonfalsey means pinned */
pinnedBy: Object, /* author-short */
flags: Array, /* chat comment flag */
stars: Array, /* used to indicate that others like the post, array of author-short */
recordedIP: String, /* private, record the IP of each message, for logging purposes */
mentions: Array, /* Array of author-short, used for fast-parsing in the room, to indicate that you were pinged */
}
chat comment history:
{
timestamp: Date, /* they're all versions of the same comment, so we don't need an id, we can order by timestamp */
body: String,
author: Object, /* author-short, moderators can rewrite the body of a text, so the author needs to be recorded */
recordedIP: String, /* private, record the IP of each modification, for logging purposes */
}
chat comment flag:
{
flaggedBy: Object, /* author-short, who flagged this */
timestamp: Date`,
type: int, /* enum */
body: String, /* if custom body text is entered */
resolved: Date, /* we just need to know when it was resolved, unresolved are falsey */
resolvedBy: Object, /* author-short, denormalized like this for display purposes, we can upDate on the fly if need be */
}
chat comment author-short:
{
id: int, /* user id */
name: String, /* used for display while you wait for things like the images and full author information to load from the id, based on the time of recording, no need to upDate it */
}
user:
{
id: int,
name: String, /* display name - not currently auditing, do we need to? */
realName: String,
location: String, /* allows the user to provide a location, if they like */
joined: Date,
lastMessage: Date,
lastSeen: Date,
about: String, /* a long-form about string */
currentlyIn: Array, /* list of user-room-timestamp */
roomsVisited: int,
messageCount: int,
email: String, /* used to generate the gravatar hash, private field */
gravatar: String, /* stored hash so we don't have to look it up everytime */
ignores: Array, /* ints of userids */
roles: Array, /* private, int list of roles that the user is part of */
owns: Array, /* list of room ids, for fast lookup */
favoriteRooms: Array, /* array of int, favorite room ids */
authTokens: Object, /* private, need some way to do OpenID, OAuth2, etc logins. Handle FB, Twitter, OpenID, etc. Let someone else's code handle this. No need for me to right now. http://stackoverflow.com/questions/4127378/is-anyone-using-node-js-with-an-oauth2-0-authentication-system */
deleted: Date, /* falsey if the user was deleted, for login restrictions and display purposes */
deletedBy: Object, /* author-short */
}
/* the goal here is: site admin, administrative/moderator user, user
* this gives the options for:
* * one or two people to manage the backend, (site admin)
* * many people to monitor usage, (moderators)
* * and most people to just use the site. (users)
* Needs more definition.
*/
roles: //private to all non-administrative users
{
id: int,
name: String
}
//also used when determining which rooms you're in for the fast-select, when loading a new page
//also used for displaying on the page of who's currently in the room
//could be used to generate the "who's usually here" list, maybe. Need to add a "dead" timestamp so we don't query it often?
users-in-room:
{
room: int, /* room id */
roomName: String, /* denormalized room name to make listing faster */
user: int, /* user-id */
userName: String, /* denormalized room name to make listing faster */
lastSeen: Date, /* garbage-collected every few minutes, makes for fast lookups */
/* proposed */ dead: Date, /* used when you leave a room, either by ping-death or "leave" */
}
rooms:
{
id: int,
created: Date,
createdBy: Object, /* author-short */
owners: Array, /* author-short */
messageCount: int, /* just a simple counter for display purposes */
name: String,
description: String,
urls: Array, /* Array of roomUrl, sometimes room owners want to supply a list of URLs for a room - not planned to hold the history here for this object */
conversations: Array, /* list of ints pointing back to the conversations created for a room. Only touched from create/delete, so can be neatly managed easily */
stars: Array, /* is this reasonable here? Probably not... Array of message ids, we can pull the rest of the information we need from the ids */
restricted: /* enum: gallery, private */,
frozen: bool,
currentTimeout: Date, /* if not-null, how long the room is in timeout until */
currentTimeoutReason: String,
currentTimeoutBy: Object, /* author-short */
allowedUsersReadWrite: Array, /* author-short, normally allowed to chat in the room, even when "gallery" */
allowedUsersReadOnly: Array, /* author-short, can read but not post */
deniedUsers: Array, /* author-short, never allowed to chat in the room */
themeCss: String, /* akin to reddit's subreddit css feature, allow each room to provide it's own CSS */
themeJavascript: String, /* room specific javascript */
}
//used in the Array of urls in room
roomUrl:
{
url: String,
text: String,
}
conversations:
{
id: int,
capturedBy: Object, /* author-short */
firstMessage: int,
lastMessage: int,
name: String,
created: Date,
}
notifications:
{
id: int,
user: Object, /* author-short, denormalized to make scanning for who is to be notified faster */
messageId: int,
viewed: Date, /* when the owner saw the post */
type: int, /* enum of what type of notification, to allow mixing moderator notifications and user notifications - use 0 for non-moderator notifications */
}
/*
in-app models for statistical captures during the day:
room message counters
user message counters
online users
active rooms
do we log?
how often a user logs in?
how often a user switches rooms?
renderer notes:
url based regex matching, message pattern being: [replyTo] url
need to be able to configure which one captures first, or give some ordering to the array of regexes, and which are not going to process at all
needs a table for monitoring this and showing it to admin only
reddit in-place voting
ability to reject certain oneboxes before you see them on screen, by-user config
handoff task: / can be a 2.0 milestone objective
need something to handle uploading images and uploading to a given image host
list of image hosts needs to be updateable and configurable by an admin
ex: imgur, imm.io, etc.
then on upload, the recv'd url needs to be inserted into the chat
Prefer to keep the "delete url" if one is given by the API in a table for the site admin to be able to delete the images, along with who uploaded the image (and when, and for what post)
socket transports in the room:
event type, event handler, event data
needs to be well defined, able to be coordinated between the client and server
needs to track stuff like:
* room owner changed
* room description changed
* user joins room
* user leaves room
* new message posted
* message edited
* message deleted
* last message in "in rooms" updated
2.0 milestones:
events
feeds
tags
search
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment