events & global sync. unstable
This commit is contained in:
1 parent
77921ba6a8
commit
f140181c45
21 files changed
+1196
-31
No files matched your search
@@ -11,6 +11,7 @@ from app.core.models.content.user_content import UserContent, UserAction
|
||||
from app.core.models._config import ServiceConfigValue, ServiceConfig
|
||||
from app.core.models.asset import Asset
|
||||
from app.core.models.my_network import KnownNode, KnownNodeIncident, RemoteContentIndex
|
||||
from app.core.models.events import NodeEvent, NodeEventCursor
|
||||
from app.core.models.promo import PromoAction
|
||||
from app.core.models.tasks import BlockchainTask
|
||||
from app.core.models.content_v3 import (
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import (
|
||||
Column,
|
||||
Integer,
|
||||
BigInteger,
|
||||
String,
|
||||
DateTime,
|
||||
JSON,
|
||||
UniqueConstraint,
|
||||
)
|
||||
|
||||
from .base import AlchemyBase
|
||||
|
||||
|
||||
class NodeEvent(AlchemyBase):
|
||||
__tablename__ = 'node_events'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('origin_public_key', 'seq', name='uq_node_events_origin_seq'),
|
||||
UniqueConstraint('uid', name='uq_node_events_uid'),
|
||||
)
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
origin_public_key = Column(String(128), nullable=False)
|
||||
origin_host = Column(String(256), nullable=True)
|
||||
seq = Column(BigInteger, nullable=False)
|
||||
uid = Column(String(64), nullable=False)
|
||||
event_type = Column(String(64), nullable=False)
|
||||
payload = Column(JSON, nullable=False, default=dict)
|
||||
signature = Column(String(512), nullable=False)
|
||||
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
received_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
applied_at = Column(DateTime, nullable=True)
|
||||
status = Column(String(32), nullable=False, default='recorded')
|
||||
|
||||
|
||||
class NodeEventCursor(AlchemyBase):
|
||||
__tablename__ = 'node_event_cursors'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('source_public_key', name='uq_event_cursor_source'),
|
||||
)
|
||||
|
||||
id = Column(Integer, autoincrement=True, primary_key=True)
|
||||
source_public_key = Column(String(128), nullable=False)
|
||||
last_seq = Column(BigInteger, nullable=False, default=0)
|
||||
updated_at = Column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
source_public_host = Column(String(256), nullable=True)
|
||||
@@ -49,8 +49,15 @@ class StarsInvoice(AlchemyBase):
|
||||
|
||||
user_id = Column(Integer, ForeignKey('users.id'), nullable=True)
|
||||
content_hash = Column(String(256), nullable=True)
|
||||
telegram_id = Column(Integer, nullable=True)
|
||||
|
||||
invoice_url = Column(String(256), nullable=True)
|
||||
paid = Column(Boolean, nullable=False, default=False)
|
||||
paid_at = Column(DateTime, nullable=True)
|
||||
payment_tx_id = Column(String(256), nullable=True)
|
||||
payment_node_id = Column(String(128), nullable=True)
|
||||
payment_node_public_host = Column(String(256), nullable=True)
|
||||
bot_username = Column(String(128), nullable=True)
|
||||
is_remote = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
created = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
@@ -1,5 +1,5 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, Integer, String, BigInteger, DateTime, JSON
|
||||
from sqlalchemy import Column, Integer, String, BigInteger, DateTime, JSON, Boolean
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from app.core.auth_v1 import AuthenticationMixin as AuthenticationMixin_V1
|
||||
@@ -23,6 +23,7 @@ class User(AlchemyBase, DisplayMixin, TranslationCore, AuthenticationMixin_V1, W
|
||||
username = Column(String(512), nullable=True)
|
||||
lang_code = Column(String(8), nullable=False, default="en")
|
||||
meta = Column(JSON, nullable=False, default=dict)
|
||||
is_admin = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
last_use = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
updated = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
Reference in new issue
Block a user