pnut-matrix/models.py

75 lines
2.3 KiB
Python
Raw Permalink Normal View History

2017-03-04 19:29:44 +00:00
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class MatrixUser(db.Model):
id = db.Column(db.Integer, primary_key=True)
matrix_id = db.Column(db.Text, unique=True)
room_id = db.Column(db.Text)
pnut_id = db.Column(db.Text, unique=True)
pnut_token = db.Column(db.Text)
def __init__(self, matrix_id, room_id, pnut_id, pnut_token):
self.matrix_id = matrix_id
self.room_id = room_id
self.pnut_id = pnut_id
self.pnut_token = pnut_token
def __repr__(self):
2017-03-04 20:54:43 +00:00
return '<MatrixUser %r>' % self.matrix_id
class MatrixRoom(db.Model):
id = db.Column(db.Integer, primary_key=True)
room_id = db.Column(db.Text, unique=True)
pnut_chan = db.Column(db.Text)
pnut_since = db.Column(db.Text)
pnut_write = db.Column(db.Boolean, default=True)
def __init__(self, room_id, pnut_chan, pnut_write=True):
self.room_id = room_id
self.pnut_chan = pnut_chan
self.pnut_write = pnut_write
def __repr__(self):
return '<MatrixRoom %r>' % self.room_id
class MatrixRoom2(db.Model):
id = db.Column(db.Integer, primary_key=True)
room_id = db.Column(db.Text, unique=True)
pnut_chan = db.Column(db.Text, unique=True)
pnut_since = db.Column(db.Text)
pnut_write = db.Column(db.Boolean, default=True)
def __init__(self, room_id, pnut_chan, pnut_write=True):
2017-03-04 20:54:43 +00:00
self.room_id = room_id
self.pnut_chan = pnut_chan
self.pnut_write = pnut_write
def __repr__(self):
return '<MatrixRoom %r>' % self.room_id
2017-03-04 21:43:30 +00:00
class MatrixMsgEvents(db.Model):
id = db.Column(db.Integer, primary_key=True)
event_id = db.Column(db.Text)
room_id = db.Column(db.Text)
pnut_msgid = db.Column(db.Text)
pnut_user = db.Column(db.Text)
pnut_chan = db.Column(db.Text)
deleted = db.Column(db.Boolean, default=False)
def __init__(self, event_id, room_id, pnut_msgid, pnut_user, pnut_chan):
self.event_id = event_id
self.room_id = room_id
self.pnut_msgid = pnut_msgid
self.pnut_user = pnut_user
self.pnut_chan = pnut_chan
2017-05-04 06:02:13 +00:00
class MatrixAdminRooms(db.Model):
id = db.Column(db.Integer, primary_key=True)
matrix_id = db.Column(db.Text)
room_id = db.Column(db.Text)
def __init__(self, matrix_id, room_id):
self.matrix_id = matrix_id
self.room_id = room_id