Implement message reply/forward bridging in both directions

This commit is contained in:
Tulir Asokan
2018-01-22 21:20:56 +02:00
parent aaaf52576c
commit 8a3ccb6e8c
8 changed files with 113 additions and 30 deletions
+12 -3
View File
@@ -13,9 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sqlalchemy import orm, \
Column, ForeignKey, \
Integer, String
from sqlalchemy import Column, ForeignKey, UniqueConstraint, Integer, String
from sqlalchemy.orm.scoping import scoped_session
from .base import Base
@@ -36,6 +34,16 @@ class Portal(Base):
photo_id = Column(String, nullable=True)
class Message(Base):
__tablename__ = "message"
mxid = Column(String)
mx_room = Column(String)
tgid = Column(Integer, primary_key=True)
user = Column(Integer, ForeignKey("user.tgid"), primary_key=True)
__table_args__ = (UniqueConstraint('mxid', 'mx_room', name='_mx_id_room'), )
class User(Base):
__tablename__ = "user"
@@ -55,5 +63,6 @@ class Puppet(Base):
def init(db_factory):
db = scoped_session(db_factory)
Portal.query = db.query_property()
Message.query = db.query_property()
User.query = db.query_property()
Puppet.query = db.query_property()