
* Integrate chat from upstream Substantially borrowed from upstream ref: 13a208ee88e55 (before they started editing generated artefacts instead of source). Integrated, including: - Remove previously removed features: emoji, hats, and name colors - Compensate for lack of unified root template - Add React build process to Dockerfile and `bootstrap/init.sh` - Preliminary integration of chat websocket workers For testing, modify `supervisord.conf.dev` to put chat on port 80 and the site service on some other port. Then visit: http://localhost/chat Still to do: - Access control for specific small-groups (and admins probably): Set the values somewhere (site_settings.json? Redis?) and use for authorization in `chat_is_allowed`. - Proxying only /chat to the websocket workers - Chat persistance across restarts: either Redis devops or to DB * Add nginx server to do appropriate redirection. * Add necessary columns to User. * Wire up chat permissions. * Reload chat on source change. * Add a better structure for slash commands and add/remove functionality. * Stop putting up previews of slash commands. * We require more whitespace. * Strip DMs out entirely, I currently do not want to deal with them. * Change "Users Online" to just "Users". * Clean up a little more DM detritus. * Save chat history in database. * Remove unnecessary hefty query to the DB. * Clean up optimistic messages. * Initial implementation of notification icon. * Update readme a little bit. * Fix notification highlight (mostly). * Remove chat version number that will never be updated. * Fix: Errors on logged-out users. * Add function to nuke the chat state. * Update DB. * Add a dedicated deployable docker image. * Fix: init_build.sh execute bit not set. * Whoops, screwed up the abort() call. * Relax chat rate limiter. * Remove a somewhat silly comment. * Remove an unnecessary g.db.add(). --------- Co-authored-by: TLSM <duolsm@outlook.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
|
|
from files.classes.base import CreatedDateTimeBase
|
|
from files.helpers.lazy import lazy
|
|
from sqlalchemy import *
|
|
from sqlalchemy.orm import declared_attr, relationship
|
|
|
|
class ChatMessage(CreatedDateTimeBase):
|
|
__tablename__ = "chat_message"
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
author_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
quote_id = Column(Integer, ForeignKey("chat_message.id"), nullable=True)
|
|
text = Column(String, nullable=False)
|
|
text_html = Column(String, nullable=False)
|
|
|
|
author = relationship("User", primaryjoin="User.id==ChatMessage.author_id")
|
|
|
|
@declared_attr
|
|
def created_datetimez_index(self):
|
|
return Index('created_datetimez_index', self.created_datetimez)
|
|
|
|
Index('quote_index', quote_id)
|
|
|
|
@lazy
|
|
def json_speak(self):
|
|
data = {
|
|
'id': str(self.id),
|
|
'quotes': None if self.quote_id is None else str(self.quote_id),
|
|
'avatar': self.author.profile_url,
|
|
'username': self.author.username,
|
|
'text': self.text,
|
|
'text_html': self.text_html,
|
|
'time': int(self.created_datetimez.timestamp()),
|
|
}
|
|
|
|
return data
|