forked from rDrama/rDrama
Merge remote-tracking branch 'origin/master'
# Conflicts: # files/templates/default.htmlmaster
commit
6fd0d87477
|
@ -17,7 +17,7 @@ import gevent
|
||||||
from redis import ConnectionPool
|
from redis import ConnectionPool
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='./templates', static_folder='./static')
|
app = Flask(__name__, template_folder='./templates')
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3)
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3)
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
app.jinja_env.cache = {}
|
app.jinja_env.cache = {}
|
||||||
|
@ -83,7 +83,7 @@ limiter = Limiter(
|
||||||
_engine=create_engine(
|
_engine=create_engine(
|
||||||
app.config['DATABASE_URL'],
|
app.config['DATABASE_URL'],
|
||||||
poolclass=QueuePool,
|
poolclass=QueuePool,
|
||||||
pool_size=int(environ.get("PG_POOL_SIZE",10)),
|
pool_size=197,
|
||||||
pool_use_lifo=True
|
pool_use_lifo=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -64,17 +64,10 @@ class AwardRelationship(Base):
|
||||||
comment_id = Column(Integer, ForeignKey("comments.id"), default=None)
|
comment_id = Column(Integer, ForeignKey("comments.id"), default=None)
|
||||||
kind = Column(String(20))
|
kind = Column(String(20))
|
||||||
|
|
||||||
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", lazy="joined")
|
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", lazy="joined", viewonly=True)
|
||||||
post = relationship(
|
|
||||||
"Submission",
|
post = relationship("Submission", primaryjoin="AwardRelationship.submission_id==Submission.id", lazy="joined", viewonly=True)
|
||||||
primaryjoin="AwardRelationship.submission_id==Submission.id",
|
comment = relationship("Comment", primaryjoin="AwardRelationship.comment_id==Comment.id", lazy="joined", viewonly=True)
|
||||||
lazy="joined"
|
|
||||||
)
|
|
||||||
comment = relationship(
|
|
||||||
"Comment",
|
|
||||||
primaryjoin="AwardRelationship.comment_id==Comment.id",
|
|
||||||
lazy="joined"
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def given(self):
|
def given(self):
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Badge(Base):
|
||||||
badge_id = Column(Integer, ForeignKey("badge_defs.id"))
|
badge_id = Column(Integer, ForeignKey("badge_defs.id"))
|
||||||
description = Column(String(64))
|
description = Column(String(64))
|
||||||
url = Column(String(256))
|
url = Column(String(256))
|
||||||
badge = relationship("BadgeDef", lazy="joined", innerjoin=True)
|
badge = relationship("BadgeDef", lazy="joined", innerjoin=True, viewonly=True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class OauthApp(Base, Stndrd):
|
||||||
redirect_uri = Column(String(4096))
|
redirect_uri = Column(String(4096))
|
||||||
description = Column(String(256))
|
description = Column(String(256))
|
||||||
author_id = Column(Integer, ForeignKey("users.id"))
|
author_id = Column(Integer, ForeignKey("users.id"))
|
||||||
author = relationship("User")
|
author = relationship("User", viewonly=True)
|
||||||
|
|
||||||
def __repr__(self): return f"<OauthApp(id={self.id})>"
|
def __repr__(self): return f"<OauthApp(id={self.id})>"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class OauthApp(Base, Stndrd):
|
||||||
|
|
||||||
def idlist(self, page=1, **kwargs):
|
def idlist(self, page=1, **kwargs):
|
||||||
|
|
||||||
posts = g.db.query(Submission.id).options(lazyload('*')).filter_by(app_id=self.id)
|
posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id)
|
||||||
|
|
||||||
posts=posts.order_by(Submission.created_utc.desc())
|
posts=posts.order_by(Submission.created_utc.desc())
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class OauthApp(Base, Stndrd):
|
||||||
|
|
||||||
def comments_idlist(self, page=1, **kwargs):
|
def comments_idlist(self, page=1, **kwargs):
|
||||||
|
|
||||||
posts = g.db.query(Comment.id).options(lazyload('*')).filter_by(app_id=self.id)
|
posts = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id)
|
||||||
|
|
||||||
posts=posts.order_by(Comment.created_utc.desc())
|
posts=posts.order_by(Comment.created_utc.desc())
|
||||||
|
|
||||||
|
@ -53,5 +53,5 @@ class ClientAuth(Base, Stndrd):
|
||||||
oauth_client = Column(Integer, ForeignKey("oauth_apps.id"))
|
oauth_client = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
access_token = Column(String(128))
|
access_token = Column(String(128))
|
||||||
user_id = Column(Integer, ForeignKey("users.id"))
|
user_id = Column(Integer, ForeignKey("users.id"))
|
||||||
user = relationship("User", lazy="joined")
|
user = relationship("User", lazy="joined", viewonly=True)
|
||||||
application = relationship("OauthApp", lazy="joined")
|
application = relationship("OauthApp", lazy="joined", viewonly=True)
|
|
@ -28,12 +28,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
||||||
__tablename__ = "comments"
|
__tablename__ = "comments"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
comment_aux = relationship(
|
comment_aux = relationship("CommentAux", lazy="joined", uselist=False, innerjoin=True, primaryjoin="Comment.id==CommentAux.id", viewonly=True)
|
||||||
"CommentAux",
|
|
||||||
lazy="joined",
|
|
||||||
uselist=False,
|
|
||||||
innerjoin=True,
|
|
||||||
primaryjoin="Comment.id==CommentAux.id")
|
|
||||||
author_id = Column(Integer, ForeignKey("users.id"))
|
author_id = Column(Integer, ForeignKey("users.id"))
|
||||||
parent_submission = Column(Integer, ForeignKey("submissions.id"))
|
parent_submission = Column(Integer, ForeignKey("submissions.id"))
|
||||||
# this column is foreignkeyed to comment(id) but we can't do that yet as
|
# this column is foreignkeyed to comment(id) but we can't do that yet as
|
||||||
|
@ -55,23 +50,19 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
||||||
sentto=Column(Integer)
|
sentto=Column(Integer)
|
||||||
|
|
||||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
oauth_app=relationship("OauthApp")
|
oauth_app=relationship("OauthApp", viewonly=True)
|
||||||
|
|
||||||
post = relationship("Submission")
|
post = relationship("Submission", viewonly=True)
|
||||||
flags = relationship("CommentFlag", lazy="dynamic")
|
flags = relationship("CommentFlag", lazy="dynamic", viewonly=True)
|
||||||
author = relationship(
|
author = relationship("User", lazy="joined", innerjoin=True, primaryjoin="User.id==Comment.author_id", viewonly=True)
|
||||||
"User",
|
|
||||||
lazy="joined",
|
|
||||||
innerjoin=True,
|
|
||||||
primaryjoin="User.id==Comment.author_id")
|
|
||||||
|
|
||||||
upvotes = Column(Integer, default=1)
|
upvotes = Column(Integer, default=1)
|
||||||
downvotes = Column(Integer, default=0)
|
downvotes = Column(Integer, default=0)
|
||||||
|
|
||||||
parent_comment = relationship("Comment", remote_side=[id])
|
parent_comment = relationship("Comment", remote_side=[id], viewonly=True)
|
||||||
child_comments = relationship("Comment", remote_side=[parent_comment_id])
|
child_comments = relationship("Comment", remote_side=[parent_comment_id], viewonly=True)
|
||||||
|
|
||||||
awards = relationship("AwardRelationship", lazy="joined")
|
awards = relationship("AwardRelationship", lazy="joined", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
@ -344,8 +335,8 @@ class Notification(Base):
|
||||||
blocksender = Column(Integer)
|
blocksender = Column(Integer)
|
||||||
unblocksender = Column(Integer)
|
unblocksender = Column(Integer)
|
||||||
|
|
||||||
comment = relationship("Comment", lazy="joined", innerjoin=True)
|
comment = relationship("Comment", lazy="joined", innerjoin=True, viewonly=True)
|
||||||
user=relationship("User", innerjoin=True)
|
user=relationship("User", innerjoin=True, viewonly=True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Flag(Base, Stndrd):
|
||||||
user_id = Column(Integer, ForeignKey("users.id"))
|
user_id = Column(Integer, ForeignKey("users.id"))
|
||||||
reason = Column(String(100))
|
reason = Column(String(100))
|
||||||
|
|
||||||
user = relationship("User", lazy = "joined", primaryjoin = "Flag.user_id == User.id", uselist = False)
|
user = relationship("User", lazy = "joined", primaryjoin = "Flag.user_id == User.id", uselist = False, viewonly=True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class CommentFlag(Base, Stndrd):
|
||||||
comment_id = Column(Integer, ForeignKey("comments.id"))
|
comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||||
reason = Column(String(100))
|
reason = Column(String(100))
|
||||||
|
|
||||||
user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False)
|
user = relationship("User", lazy = "joined", primaryjoin = "CommentFlag.user_id == User.id", uselist = False, viewonly=True)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ class ModAction(Base, Stndrd, Age_times):
|
||||||
created_utc = Column(Integer, default=0)
|
created_utc = Column(Integer, default=0)
|
||||||
|
|
||||||
|
|
||||||
user = relationship("User", lazy="joined", primaryjoin="User.id==ModAction.user_id")
|
user = relationship("User", lazy="joined", primaryjoin="User.id==ModAction.user_id", viewonly=True)
|
||||||
target_user = relationship("User", lazy="joined", primaryjoin="User.id==ModAction.target_user_id")
|
target_user = relationship("User", lazy="joined", primaryjoin="User.id==ModAction.target_user_id", viewonly=True)
|
||||||
target_post = relationship("Submission", lazy="joined")
|
target_post = relationship("Submission", lazy="joined", viewonly=True)
|
||||||
target_comment = relationship("Comment", lazy="joined")
|
target_comment = relationship("Comment", lazy="joined", viewonly=True)
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
@ -33,12 +33,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
__tablename__ = "submissions"
|
__tablename__ = "submissions"
|
||||||
|
|
||||||
id = Column(BigInteger, primary_key=True)
|
id = Column(BigInteger, primary_key=True)
|
||||||
submission_aux = relationship(
|
submission_aux = relationship("SubmissionAux", lazy="joined", uselist=False, innerjoin=True, primaryjoin="Submission.id==SubmissionAux.id", viewonly=True)
|
||||||
"SubmissionAux",
|
|
||||||
lazy="joined",
|
|
||||||
uselist=False,
|
|
||||||
innerjoin=True,
|
|
||||||
primaryjoin="Submission.id==SubmissionAux.id")
|
|
||||||
author_id = Column(BigInteger, ForeignKey("users.id"))
|
author_id = Column(BigInteger, ForeignKey("users.id"))
|
||||||
edited_utc = Column(BigInteger, default=0)
|
edited_utc = Column(BigInteger, default=0)
|
||||||
created_utc = Column(BigInteger, default=0)
|
created_utc = Column(BigInteger, default=0)
|
||||||
|
@ -56,19 +51,11 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
private = Column(Boolean, default=False)
|
private = Column(Boolean, default=False)
|
||||||
club = Column(Boolean, default=False)
|
club = Column(Boolean, default=False)
|
||||||
comment_count = Column(Integer, default=0)
|
comment_count = Column(Integer, default=0)
|
||||||
comments = relationship(
|
comments = relationship("Comment", lazy="joined", primaryjoin="Comment.parent_submission==Submission.id", viewonly=True)
|
||||||
"Comment",
|
flags = relationship("Flag", lazy="dynamic", viewonly=True)
|
||||||
lazy="joined",
|
|
||||||
primaryjoin="Comment.parent_submission==Submission.id",
|
|
||||||
)
|
|
||||||
flags = relationship("Flag", lazy="dynamic")
|
|
||||||
is_approved = Column(Integer, ForeignKey("users.id"), default=0)
|
is_approved = Column(Integer, ForeignKey("users.id"), default=0)
|
||||||
over_18 = Column(Boolean, default=False)
|
over_18 = Column(Boolean, default=False)
|
||||||
author = relationship(
|
author = relationship("User", lazy="joined", innerjoin=True, primaryjoin="Submission.author_id==User.id", viewonly=True)
|
||||||
"User",
|
|
||||||
lazy="joined",
|
|
||||||
innerjoin=True,
|
|
||||||
primaryjoin="Submission.author_id==User.id")
|
|
||||||
is_pinned = Column(Boolean, default=False)
|
is_pinned = Column(Boolean, default=False)
|
||||||
is_bot = Column(Boolean, default=False)
|
is_bot = Column(Boolean, default=False)
|
||||||
|
|
||||||
|
@ -76,14 +63,11 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
||||||
downvotes = Column(Integer, default=0)
|
downvotes = Column(Integer, default=0)
|
||||||
|
|
||||||
app_id=Column(Integer, ForeignKey("oauth_apps.id"))
|
app_id=Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
oauth_app=relationship("OauthApp")
|
oauth_app=relationship("OauthApp", viewonly=True)
|
||||||
|
|
||||||
approved_by = relationship(
|
approved_by = relationship("User", uselist=False, primaryjoin="Submission.is_approved==User.id", viewonly=True)
|
||||||
"User",
|
|
||||||
uselist=False,
|
|
||||||
primaryjoin="Submission.is_approved==User.id")
|
|
||||||
|
|
||||||
awards = relationship("AwardRelationship", lazy="joined")
|
awards = relationship("AwardRelationship", lazy="joined", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from files.__main__ import Base
|
from files.__main__ import Base
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
class Subscription(Base):
|
class Subscription(Base):
|
||||||
|
@ -10,7 +9,7 @@ class Subscription(Base):
|
||||||
user_id = Column(BigInteger, ForeignKey("users.id"))
|
user_id = Column(BigInteger, ForeignKey("users.id"))
|
||||||
submission_id = Column(BigInteger, default=0)
|
submission_id = Column(BigInteger, default=0)
|
||||||
|
|
||||||
user = relationship("User", uselist=False)
|
user = relationship("User", uselist=False, viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -25,14 +24,8 @@ class Follow(Base):
|
||||||
user_id = Column(BigInteger, ForeignKey("users.id"))
|
user_id = Column(BigInteger, ForeignKey("users.id"))
|
||||||
target_id = Column(BigInteger, ForeignKey("users.id"))
|
target_id = Column(BigInteger, ForeignKey("users.id"))
|
||||||
|
|
||||||
user = relationship(
|
user = relationship("User", uselist=False, primaryjoin="User.id==Follow.user_id", viewonly=True)
|
||||||
"User",
|
target = relationship("User", lazy="joined", primaryjoin="User.id==Follow.target_id", viewonly=True)
|
||||||
uselist=False,
|
|
||||||
primaryjoin="User.id==Follow.user_id")
|
|
||||||
target = relationship(
|
|
||||||
"User",
|
|
||||||
lazy="joined",
|
|
||||||
primaryjoin="User.id==Follow.target_id")
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -23,6 +23,53 @@ defaultcolor = environ.get("DEFAULT_COLOR", "fff").strip()
|
||||||
defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
|
defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
|
||||||
cardview = bool(int(environ.get("CARD_VIEW", 1)))
|
cardview = bool(int(environ.get("CARD_VIEW", 1)))
|
||||||
|
|
||||||
|
if site_name == "Drama":
|
||||||
|
AWARDS = {
|
||||||
|
"ban": {
|
||||||
|
"kind": "ban",
|
||||||
|
"title": "One-Day Ban",
|
||||||
|
"description": "Bans the author for a day.",
|
||||||
|
"icon": "fas fa-gavel",
|
||||||
|
"color": "text-danger",
|
||||||
|
"price": 5000
|
||||||
|
},
|
||||||
|
"shit": {
|
||||||
|
"kind": "shit",
|
||||||
|
"title": "Shit",
|
||||||
|
"description": "Makes flies swarm a post.",
|
||||||
|
"icon": "fas fa-poop",
|
||||||
|
"color": "text-black-50",
|
||||||
|
"price": 1000
|
||||||
|
},
|
||||||
|
"stars": {
|
||||||
|
"kind": "stars",
|
||||||
|
"title": "Stars",
|
||||||
|
"description": "Puts stars on the post.",
|
||||||
|
"icon": "fas fa-sparkles",
|
||||||
|
"color": "text-warning",
|
||||||
|
"price": 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
AWARDS = {
|
||||||
|
"shit": {
|
||||||
|
"kind": "shit",
|
||||||
|
"title": "shit",
|
||||||
|
"description": "Makes flies swarm a post.",
|
||||||
|
"icon": "fas fa-poop",
|
||||||
|
"color": "text-black-50",
|
||||||
|
"price": 1000
|
||||||
|
},
|
||||||
|
"stars": {
|
||||||
|
"kind": "stars",
|
||||||
|
"title": "Stars",
|
||||||
|
"description": "Puts stars on the post.",
|
||||||
|
"icon": "fas fa-sparkles",
|
||||||
|
"color": "text-warning",
|
||||||
|
"price": 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class User(Base, Stndrd, Age_times):
|
class User(Base, Stndrd, Age_times):
|
||||||
__tablename__ = "users"
|
__tablename__ = "users"
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
@ -76,20 +123,12 @@ class User(Base, Stndrd, Age_times):
|
||||||
oldreddit = Column(Boolean)
|
oldreddit = Column(Boolean)
|
||||||
nitter = Column(Boolean)
|
nitter = Column(Boolean)
|
||||||
controversial = Column(Boolean, default=False)
|
controversial = Column(Boolean, default=False)
|
||||||
submissions = relationship(
|
submissions = relationship("Submission", lazy="dynamic", primaryjoin="Submission.author_id==User.id", viewonly=True)
|
||||||
"Submission",
|
comments = relationship("Comment", lazy="dynamic", primaryjoin="Comment.author_id==User.id", viewonly=True)
|
||||||
lazy="dynamic",
|
|
||||||
primaryjoin="Submission.author_id==User.id")
|
|
||||||
comments = relationship(
|
|
||||||
"Comment",
|
|
||||||
lazy="dynamic",
|
|
||||||
primaryjoin="Comment.author_id==User.id")
|
|
||||||
bio = Column(String)
|
bio = Column(String)
|
||||||
bio_html = Column(String)
|
bio_html = Column(String)
|
||||||
badges = relationship("Badge", lazy="dynamic")
|
badges = relationship("Badge", lazy="dynamic", viewonly=True)
|
||||||
notifications = relationship(
|
notifications = relationship("Notification", lazy="dynamic", viewonly=True)
|
||||||
"Notification",
|
|
||||||
lazy="dynamic")
|
|
||||||
|
|
||||||
is_banned = Column(Integer, default=0)
|
is_banned = Column(Integer, default=0)
|
||||||
unban_utc = Column(Integer, default=0)
|
unban_utc = Column(Integer, default=0)
|
||||||
|
@ -112,31 +151,24 @@ class User(Base, Stndrd, Age_times):
|
||||||
discord_id = Column(String(64))
|
discord_id = Column(String(64))
|
||||||
ban_evade = Column(Integer, default=0)
|
ban_evade = Column(Integer, default=0)
|
||||||
original_username = deferred(Column(String(255)))
|
original_username = deferred(Column(String(255)))
|
||||||
subscriptions = relationship("Subscription")
|
subscriptions = relationship("Subscription", viewonly=True)
|
||||||
|
|
||||||
following = relationship("Follow", primaryjoin="Follow.user_id==User.id")
|
following = relationship("Follow", primaryjoin="Follow.user_id==User.id", viewonly=True)
|
||||||
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id")
|
followers = relationship("Follow", primaryjoin="Follow.target_id==User.id", viewonly=True)
|
||||||
|
|
||||||
viewers = relationship("ViewerRelationship", primaryjoin="User.id == ViewerRelationship.user_id")
|
viewers = relationship("ViewerRelationship", primaryjoin="User.id == ViewerRelationship.user_id", viewonly=True)
|
||||||
|
|
||||||
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id")
|
blocking = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
||||||
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id")
|
blocked = relationship("UserBlock", lazy="dynamic", primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
||||||
|
|
||||||
_applications = relationship("OauthApp", lazy="dynamic")
|
_applications = relationship("OauthApp", lazy="dynamic", viewonly=True)
|
||||||
authorizations = relationship("ClientAuth", lazy="dynamic")
|
authorizations = relationship("ClientAuth", lazy="dynamic", viewonly=True)
|
||||||
|
|
||||||
awards = relationship(
|
awards = relationship("AwardRelationship", lazy="dynamic", primaryjoin="User.id==AwardRelationship.user_id", viewonly=True)
|
||||||
"AwardRelationship",
|
|
||||||
lazy="dynamic",
|
|
||||||
primaryjoin="User.id==AwardRelationship.user_id"
|
|
||||||
)
|
|
||||||
|
|
||||||
referred_by = Column(Integer, ForeignKey("users.id"))
|
referred_by = Column(Integer, ForeignKey("users.id"))
|
||||||
|
|
||||||
referrals = relationship(
|
referrals = relationship("User", lazy="joined", viewonly=True)
|
||||||
"User",
|
|
||||||
lazy="joined"
|
|
||||||
)
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
|
@ -148,6 +180,18 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lazy
|
||||||
|
def user_awards(v):
|
||||||
|
|
||||||
|
return_value = list(AWARDS.values())
|
||||||
|
|
||||||
|
user_awards = v.awards
|
||||||
|
|
||||||
|
for val in return_value: val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count()
|
||||||
|
|
||||||
|
return return_value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def referral_count(self):
|
def referral_count(self):
|
||||||
|
@ -155,7 +199,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
def has_block(self, target):
|
def has_block(self, target):
|
||||||
|
|
||||||
return g.db.query(UserBlock).filter_by(
|
return g.db.query(UserBlock).options(lazyload('*')).filter_by(
|
||||||
user_id=self.id, target_id=target.id).first()
|
user_id=self.id, target_id=target.id).first()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -164,7 +208,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
def any_block_exists(self, other):
|
def any_block_exists(self, other):
|
||||||
|
|
||||||
return g.db.query(UserBlock).filter(
|
return g.db.query(UserBlock).options(lazyload('*')).filter(
|
||||||
or_(and_(UserBlock.user_id == self.id, UserBlock.target_id == other.id), and_(
|
or_(and_(UserBlock.user_id == self.id, UserBlock.target_id == other.id), and_(
|
||||||
UserBlock.user_id == other.id, UserBlock.target_id == self.id))).first()
|
UserBlock.user_id == other.id, UserBlock.target_id == self.id))).first()
|
||||||
|
|
||||||
|
@ -187,7 +231,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
if self.shadowbanned and not (v and (v.admin_level >= 3 or v.id == self.id)):
|
if self.shadowbanned and not (v and (v.admin_level >= 3 or v.id == self.id)):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
submissions = g.db.query(Submission).options(lazyload('*')).filter_by(author_id=self.id, is_pinned=False)
|
submissions = g.db.query(Submission).options(lazyload('*')).options(lazyload('*')).filter_by(author_id=self.id, is_pinned=False)
|
||||||
|
|
||||||
if not (v and (v.admin_level >= 3 or v.id == self.id)):
|
if not (v and (v.admin_level >= 3 or v.id == self.id)):
|
||||||
submissions = submissions.filter_by(deleted_utc=0, is_banned=False, private=False)
|
submissions = submissions.filter_by(deleted_utc=0, is_banned=False, private=False)
|
||||||
|
@ -233,7 +277,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
def banned_by(self):
|
def banned_by(self):
|
||||||
|
|
||||||
if not self.is_suspended: return None
|
if not self.is_suspended: return None
|
||||||
return g.db.query(User).filter_by(id=self.is_banned).first()
|
return g.db.query(User).options(lazyload('*')).filter_by(id=self.is_banned).first()
|
||||||
|
|
||||||
def has_badge(self, badgedef_id):
|
def has_badge(self, badgedef_id):
|
||||||
return self.badges.filter_by(badge_id=badgedef_id).first()
|
return self.badges.filter_by(badge_id=badgedef_id).first()
|
||||||
|
@ -288,21 +332,6 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
return f"Unban in {text}"
|
return f"Unban in {text}"
|
||||||
|
|
||||||
@property
|
|
||||||
@lazy
|
|
||||||
def display_awards(self):
|
|
||||||
|
|
||||||
awards = {}
|
|
||||||
active_awards = [x for x in self.awards if not x.given]
|
|
||||||
|
|
||||||
for a in active_awards:
|
|
||||||
if a.kind in awards:
|
|
||||||
awards[a.kind]['count'] += 1
|
|
||||||
else:
|
|
||||||
awards[a.kind] = a.type
|
|
||||||
awards[a.kind]['count'] = 1
|
|
||||||
|
|
||||||
return sorted(list(awards.values()), key=lambda x: x['kind'], reverse=True)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
|
@ -310,11 +339,11 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
awards = {}
|
awards = {}
|
||||||
|
|
||||||
posts_idlist = g.db.query(Submission.id).filter_by(author_id=self.id).subquery()
|
posts_idlist = [x[0] for x in g.db.query(Submission.id).options(lazyload('*')).filter_by(author_id=self.id).all()]
|
||||||
comments_idlist = g.db.query(Comment.id).filter_by(author_id=self.id).subquery()
|
comments_idlist = [x[0] for x in g.db.query(Comment.id).options(lazyload('*')).filter_by(author_id=self.id).all()]
|
||||||
|
|
||||||
post_awards = g.db.query(AwardRelationship).filter(AwardRelationship.submission_id.in_(posts_idlist)).all()
|
post_awards = g.db.query(AwardRelationship).options(lazyload('*')).filter(AwardRelationship.submission_id.in_(posts_idlist)).all()
|
||||||
comment_awards = g.db.query(AwardRelationship).filter(AwardRelationship.comment_id.in_(comments_idlist)).all()
|
comment_awards = g.db.query(AwardRelationship).options(lazyload('*')).filter(AwardRelationship.comment_id.in_(comments_idlist)).all()
|
||||||
|
|
||||||
total_awards = post_awards + comment_awards
|
total_awards = post_awards + comment_awards
|
||||||
|
|
||||||
|
@ -345,7 +374,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
@lazy
|
@lazy
|
||||||
def alts(self):
|
def alts(self):
|
||||||
|
|
||||||
subq = g.db.query(Alt).filter(
|
subq = g.db.query(Alt).options(lazyload('*')).filter(
|
||||||
or_(
|
or_(
|
||||||
Alt.user1 == self.id,
|
Alt.user1 == self.id,
|
||||||
Alt.user2 == self.id
|
Alt.user2 == self.id
|
||||||
|
@ -407,7 +436,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
def has_follower(self, user):
|
def has_follower(self, user):
|
||||||
|
|
||||||
return g.db.query(Follow).filter_by(target_id=self.id, user_id=user.id).first()
|
return g.db.query(Follow).options(lazyload('*')).filter_by(target_id=self.id, user_id=user.id).first()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def banner_url(self):
|
def banner_url(self):
|
||||||
|
@ -511,25 +540,25 @@ class User(Base, Stndrd, Age_times):
|
||||||
OauthApp.id.asc()).all()]
|
OauthApp.id.asc()).all()]
|
||||||
|
|
||||||
def subscribed_idlist(self, page=1):
|
def subscribed_idlist(self, page=1):
|
||||||
posts = g.db.query(Subscription.submission_id).filter_by(user_id=self.id).all()
|
posts = g.db.query(Subscription.submission_id).options(lazyload('*')).filter_by(user_id=self.id).all()
|
||||||
return [x[0] for x in posts]
|
return [x[0] for x in posts]
|
||||||
|
|
||||||
def saved_idlist(self, page=1):
|
def saved_idlist(self, page=1):
|
||||||
|
|
||||||
posts = g.db.query(Submission.id).options(lazyload('*')).filter_by(is_banned=False,
|
posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False,
|
||||||
deleted_utc=0
|
deleted_utc=0
|
||||||
)
|
)
|
||||||
|
|
||||||
saved = g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id).subquery()
|
saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).options(lazyload('*')).filter(SaveRelationship.user_id == self.id).all()]
|
||||||
posts = posts.filter(Submission.id.in_(saved))
|
posts = posts.filter(Submission.id.in_(saved))
|
||||||
|
|
||||||
if self.admin_level == 0:
|
if self.admin_level == 0:
|
||||||
blocking = g.db.query(
|
blocking = [x[0] for x in g.db.query(
|
||||||
UserBlock.target_id).filter_by(
|
UserBlock.target_id).filter_by(
|
||||||
user_id=self.id).subquery()
|
user_id=self.id).all()]
|
||||||
blocked = g.db.query(
|
blocked = [x[0] for x in g.db.query(
|
||||||
UserBlock.user_id).filter_by(
|
UserBlock.user_id).filter_by(
|
||||||
target_id=self.id).subquery()
|
target_id=self.id).all()]
|
||||||
|
|
||||||
posts = posts.filter(
|
posts = posts.filter(
|
||||||
Submission.author_id.notin_(blocking),
|
Submission.author_id.notin_(blocking),
|
||||||
|
@ -542,18 +571,18 @@ class User(Base, Stndrd, Age_times):
|
||||||
|
|
||||||
def saved_comment_idlist(self, page=1):
|
def saved_comment_idlist(self, page=1):
|
||||||
|
|
||||||
comments = g.db.query(Comment.id).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0)
|
comments = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0)
|
||||||
|
|
||||||
saved = g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id).subquery()
|
saved = [x[0] for x in g.db.query(SaveRelationship.submission_id).options(lazyload('*')).filter(SaveRelationship.user_id == self.id).all()]
|
||||||
comments = comments.filter(Comment.id.in_(saved))
|
comments = comments.filter(Comment.id.in_(saved))
|
||||||
|
|
||||||
if self.admin_level == 0:
|
if self.admin_level == 0:
|
||||||
blocking = g.db.query(
|
blocking = [x[0] for x in g.db.query(
|
||||||
UserBlock.target_id).filter_by(
|
UserBlock.target_id).filter_by(
|
||||||
user_id=self.id).subquery()
|
user_id=self.id).all()]
|
||||||
blocked = g.db.query(
|
blocked = [x[0] for x in g.db.query(
|
||||||
UserBlock.user_id).filter_by(
|
UserBlock.user_id).filter_by(
|
||||||
target_id=self.id).subquery()
|
target_id=self.id).all()]
|
||||||
|
|
||||||
comments = comments.filter(
|
comments = comments.filter(
|
||||||
Comment.author_id.notin_(blocking),
|
Comment.author_id.notin_(blocking),
|
||||||
|
@ -580,8 +609,7 @@ class ViewerRelationship(Base):
|
||||||
viewer_id = Column(Integer, ForeignKey('users.id'))
|
viewer_id = Column(Integer, ForeignKey('users.id'))
|
||||||
last_view_utc = Column(Integer)
|
last_view_utc = Column(Integer)
|
||||||
|
|
||||||
user = relationship("User", lazy="joined", primaryjoin="ViewerRelationship.user_id == User.id")
|
viewer = relationship("User", lazy="joined", primaryjoin="ViewerRelationship.viewer_id == User.id", viewonly=True)
|
||||||
viewer = relationship("User", lazy="joined", primaryjoin="ViewerRelationship.viewer_id == User.id")
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
|
@ -625,4 +653,4 @@ class ViewerRelationship(Base):
|
||||||
return f"{months}mo ago"
|
return f"{months}mo ago"
|
||||||
else:
|
else:
|
||||||
years = int(months / 12)
|
years = int(months / 12)
|
||||||
return f"{years}yr ago"
|
return f"{years}yr ago"
|
|
@ -10,14 +10,8 @@ class UserBlock(Base, Stndrd, Age_times):
|
||||||
user_id = Column(Integer, ForeignKey("users.id"))
|
user_id = Column(Integer, ForeignKey("users.id"))
|
||||||
target_id = Column(Integer, ForeignKey("users.id"))
|
target_id = Column(Integer, ForeignKey("users.id"))
|
||||||
|
|
||||||
user = relationship(
|
user = relationship("User", innerjoin=True, primaryjoin="User.id==UserBlock.user_id", viewonly=True)
|
||||||
"User",
|
target = relationship("User", innerjoin=True, primaryjoin="User.id==UserBlock.target_id", viewonly=True)
|
||||||
innerjoin=True,
|
|
||||||
primaryjoin="User.id==UserBlock.user_id")
|
|
||||||
target = relationship(
|
|
||||||
"User",
|
|
||||||
innerjoin=True,
|
|
||||||
primaryjoin="User.id==UserBlock.target_id")
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ class Vote(Base):
|
||||||
submission_id = Column(Integer, ForeignKey("submissions.id"))
|
submission_id = Column(Integer, ForeignKey("submissions.id"))
|
||||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
|
|
||||||
user = relationship("User", lazy="subquery")
|
user = relationship("User", lazy="subquery", viewonly=True)
|
||||||
post = relationship("Submission", lazy="subquery")
|
post = relationship("Submission", lazy="subquery", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ class CommentVote(Base):
|
||||||
comment_id = Column(Integer, ForeignKey("comments.id"))
|
comment_id = Column(Integer, ForeignKey("comments.id"))
|
||||||
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
|
||||||
|
|
||||||
user = relationship("User", lazy="subquery")
|
user = relationship("User", lazy="subquery", viewonly=True)
|
||||||
comment = relationship("Comment", lazy="subquery")
|
comment = relationship("Comment", lazy="subquery", viewonly=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from .sanitize import *
|
||||||
from .const import *
|
from .const import *
|
||||||
|
|
||||||
|
|
||||||
def send_notification(vid, user, text, db=None):
|
def send_notification(vid, user, text):
|
||||||
|
|
||||||
# for when working outside request context
|
# for when working outside request context
|
||||||
if isinstance(user, int):
|
if isinstance(user, int):
|
||||||
|
@ -15,9 +15,6 @@ def send_notification(vid, user, text, db=None):
|
||||||
else:
|
else:
|
||||||
uid = user.id
|
uid = user.id
|
||||||
|
|
||||||
if not db:
|
|
||||||
db = g.db
|
|
||||||
|
|
||||||
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
||||||
text = text.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
text = text.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
text_html = CustomRenderer().render(mistletoe.Document(text))
|
text_html = CustomRenderer().render(mistletoe.Document(text))
|
||||||
|
@ -28,19 +25,19 @@ def send_notification(vid, user, text, db=None):
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
)
|
)
|
||||||
db.add(new_comment)
|
g.db.add(new_comment)
|
||||||
|
|
||||||
db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
new_aux = CommentAux(id=new_comment.id,
|
new_aux = CommentAux(id=new_comment.id,
|
||||||
body=text,
|
body=text,
|
||||||
body_html=text_html,
|
body_html=text_html,
|
||||||
)
|
)
|
||||||
db.add(new_aux)
|
g.db.add(new_aux)
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id,
|
notif = Notification(comment_id=new_comment.id,
|
||||||
user_id=uid)
|
user_id=uid)
|
||||||
db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
def send_follow_notif(vid, user, text):
|
def send_follow_notif(vid, user, text):
|
||||||
|
@ -186,7 +183,7 @@ def send_admin(vid, text):
|
||||||
new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html)
|
new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html)
|
||||||
g.db.add(new_aux)
|
g.db.add(new_aux)
|
||||||
|
|
||||||
admins = g.db.query(User).filter(User.admin_level > 0).all()
|
admins = g.db.query(User).options(lazyload('*')).filter(User.admin_level > 0).all()
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
|
@ -2,6 +2,7 @@ from bs4 import BeautifulSoup
|
||||||
from flask import *
|
from flask import *
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from files.classes import BannedDomain
|
from files.classes import BannedDomain
|
||||||
|
from sqlalchemy.orm import lazyload
|
||||||
|
|
||||||
def filter_comment_html(html_text):
|
def filter_comment_html(html_text):
|
||||||
|
|
||||||
|
@ -29,8 +30,7 @@ def filter_comment_html(html_text):
|
||||||
domain_list.add(new_domain)
|
domain_list.add(new_domain)
|
||||||
|
|
||||||
# search db for domain rules that prohibit commenting
|
# search db for domain rules that prohibit commenting
|
||||||
bans = [
|
bans = [x for x in g.db.query(BannedDomain).options(lazyload('*')).filter(BannedDomain.domain.in_(list(domain_list))).all()]
|
||||||
x for x in g.db.query(BannedDomain).filter(BannedDomain.domain.in_(list(domain_list))).all()]
|
|
||||||
|
|
||||||
if bans:
|
if bans:
|
||||||
return bans
|
return bans
|
||||||
|
|
|
@ -24,7 +24,7 @@ def get_user(username, v=None, graceful=False):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
block = g.db.query(UserBlock).filter(
|
block = g.db.query(UserBlock).options(lazyload('*')).filter(
|
||||||
or_(
|
or_(
|
||||||
and_(
|
and_(
|
||||||
UserBlock.user_id == v.id,
|
UserBlock.user_id == v.id,
|
||||||
|
@ -43,16 +43,16 @@ def get_user(username, v=None, graceful=False):
|
||||||
|
|
||||||
def get_account(id, v=None):
|
def get_account(id, v=None):
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id = id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id = id).first()
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
try: id = int(str(id), 36)
|
try: id = int(str(id), 36)
|
||||||
except: abort(404)
|
except: abort(404)
|
||||||
user = g.db.query(User).filter_by(id = id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id = id).first()
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
block = g.db.query(UserBlock).filter(
|
block = g.db.query(UserBlock).options(lazyload('*')).filter(
|
||||||
or_(
|
or_(
|
||||||
and_(
|
and_(
|
||||||
UserBlock.user_id == v.id,
|
UserBlock.user_id == v.id,
|
||||||
|
@ -73,7 +73,7 @@ def get_account(id, v=None):
|
||||||
def get_post(i, v=None, graceful=False, **kwargs):
|
def get_post(i, v=None, graceful=False, **kwargs):
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
vt = g.db.query(Vote).filter_by(
|
vt = g.db.query(Vote).options(lazyload('*')).filter_by(
|
||||||
user_id=v.id, submission_id=i).subquery()
|
user_id=v.id, submission_id=i).subquery()
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ def get_posts(pids, v=None):
|
||||||
pids=tuple(pids)
|
pids=tuple(pids)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
vt = g.db.query(Vote).filter(
|
vt = g.db.query(Vote).options(lazyload('*')).filter(
|
||||||
Vote.submission_id.in_(pids),
|
Vote.submission_id.in_(pids),
|
||||||
Vote.user_id==v.id
|
Vote.user_id==v.id
|
||||||
).subquery()
|
).subquery()
|
||||||
|
@ -155,7 +155,7 @@ def get_posts(pids, v=None):
|
||||||
output[i]._is_blocking = query[i][2] or 0
|
output[i]._is_blocking = query[i][2] or 0
|
||||||
output[i]._is_blocked = query[i][3] or 0
|
output[i]._is_blocked = query[i][3] or 0
|
||||||
else:
|
else:
|
||||||
output = g.db.query(Submission,).filter(Submission.id.in_(pids)).all()
|
output = g.db.query(Submission,).options(lazyload('*')).filter(Submission.id.in_(pids)).all()
|
||||||
|
|
||||||
return sorted(output, key=lambda x: pids.index(x.id))
|
return sorted(output, key=lambda x: pids.index(x.id))
|
||||||
|
|
||||||
|
@ -163,11 +163,11 @@ def get_comment(i, v=None, graceful=False, **kwargs):
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
|
|
||||||
comment=g.db.query(Comment).filter(Comment.id == i).first()
|
comment=g.db.query(Comment).options(lazyload('*')).filter(Comment.id == i).first()
|
||||||
|
|
||||||
if not comment and not graceful: abort(404)
|
if not comment and not graceful: abort(404)
|
||||||
|
|
||||||
block = g.db.query(UserBlock).filter(
|
block = g.db.query(UserBlock).options(lazyload('*')).filter(
|
||||||
or_(
|
or_(
|
||||||
and_(
|
and_(
|
||||||
UserBlock.user_id == v.id,
|
UserBlock.user_id == v.id,
|
||||||
|
@ -179,14 +179,14 @@ def get_comment(i, v=None, graceful=False, **kwargs):
|
||||||
)
|
)
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
vts = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id)
|
vts = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id)
|
||||||
vt = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).first()
|
vt = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first()
|
||||||
comment._is_blocking = block and block.user_id == v.id
|
comment._is_blocking = block and block.user_id == v.id
|
||||||
comment._is_blocked = block and block.target_id == v.id
|
comment._is_blocked = block and block.target_id == v.id
|
||||||
comment.voted = vt.vote_type if vt else 0
|
comment.voted = vt.vote_type if vt else 0
|
||||||
|
|
||||||
else:
|
else:
|
||||||
comment = g.db.query(Comment).filter(Comment.id == i).first()
|
comment = g.db.query(Comment).options(lazyload('*')).filter(Comment.id == i).first()
|
||||||
if not comment and not graceful:abort(404)
|
if not comment and not graceful:abort(404)
|
||||||
|
|
||||||
return comment
|
return comment
|
||||||
|
@ -199,7 +199,7 @@ def get_comments(cids, v=None, load_parent=False):
|
||||||
cids=tuple(cids)
|
cids=tuple(cids)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ def get_comments(cids, v=None, load_parent=False):
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
output = g.db.query(Comment).join(Comment.author).filter(Comment.id.in_(cids), User.shadowbanned == False).all()
|
output = g.db.query(Comment).join(Comment.author).options(lazyload('*')).filter(Comment.id.in_(cids), User.shadowbanned == False).all()
|
||||||
|
|
||||||
if load_parent:
|
if load_parent:
|
||||||
parents = [x.parent_comment_id for x in output if x.parent_comment_id]
|
parents = [x.parent_comment_id for x in output if x.parent_comment_id]
|
||||||
|
@ -263,7 +263,7 @@ def get_domain(s):
|
||||||
|
|
||||||
domain_list = tuple(list(domain_list))
|
domain_list = tuple(list(domain_list))
|
||||||
|
|
||||||
doms = [x for x in g.db.query(BannedDomain).filter(
|
doms = [x for x in g.db.query(BannedDomain).options(lazyload('*')).filter(
|
||||||
BannedDomain.domain.in_(domain_list)).all()]
|
BannedDomain.domain.in_(domain_list)).all()]
|
||||||
|
|
||||||
if not doms:
|
if not doms:
|
||||||
|
|
|
@ -13,7 +13,7 @@ def get_logged_in_user():
|
||||||
token = request.headers.get("Authorization")
|
token = request.headers.get("Authorization")
|
||||||
if not token: return None
|
if not token: return None
|
||||||
|
|
||||||
client = g.db.query(ClientAuth).filter(ClientAuth.access_token == token).first()
|
client = g.db.query(ClientAuth).options(lazyload('*')).filter(ClientAuth.access_token == token).first()
|
||||||
|
|
||||||
x = (client.user, client) if client else (None, None)
|
x = (client.user, client) if client else (None, None)
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def get_logged_in_user():
|
||||||
nonce = session.get("login_nonce", 0)
|
nonce = session.get("login_nonce", 0)
|
||||||
if not uid: x= (None, None)
|
if not uid: x= (None, None)
|
||||||
try:
|
try:
|
||||||
if g.db: v = g.db.query(User).filter_by(id=uid).first()
|
if g.db: v = g.db.query(User).options(lazyload('*')).filter_by(id=uid).first()
|
||||||
else: v = None
|
else: v = None
|
||||||
except: v = None
|
except: v = None
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ def check_ban_evade(v):
|
||||||
v.ban(reason="ban evasion")
|
v.ban(reason="ban evasion")
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, v, "Your account has been permanently suspended for the following reason:\n\n> ban evasion")
|
send_notification(NOTIFICATIONS_ACCOUNT, v, "Your account has been permanently suspended for the following reason:\n\n> ban evasion")
|
||||||
|
|
||||||
for post in g.db.query(Submission).filter_by(author_id=v.id).all():
|
for post in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=v.id).all():
|
||||||
if post.is_banned:
|
if post.is_banned:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ def check_ban_evade(v):
|
||||||
|
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
for comment in g.db.query(Comment).filter_by(author_id=v.id).all():
|
for comment in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=v.id).all():
|
||||||
if comment.is_banned:
|
if comment.is_banned:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -92,15 +92,14 @@ def check_ban_evade(v):
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
g.db.flush()
|
|
||||||
try: abort(403)
|
try: abort(403)
|
||||||
except Exception as e: print(e)
|
except Exception as e: print(e)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
v.ban_evade +=1
|
v.ban_evade +=1
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
|
g.db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,48 +211,4 @@ def validate_formkey(f):
|
||||||
return f(*args, v=v, **kwargs)
|
return f(*args, v=v, **kwargs)
|
||||||
|
|
||||||
wrapper.__name__ = f.__name__
|
wrapper.__name__ = f.__name__
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def api(*scopes, no_ban=False):
|
|
||||||
|
|
||||||
def wrapper_maker(f):
|
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
|
|
||||||
if request.path.startswith(('/api/v1','/api/v2')):
|
|
||||||
|
|
||||||
v = kwargs.get('v')
|
|
||||||
|
|
||||||
result = f(*args, **kwargs)
|
|
||||||
|
|
||||||
if isinstance(result, dict):
|
|
||||||
resp = result['api']()
|
|
||||||
else:
|
|
||||||
resp = result
|
|
||||||
|
|
||||||
if not isinstance(resp, RespObj):
|
|
||||||
resp = make_response(resp)
|
|
||||||
|
|
||||||
return resp
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
result = f(*args, **kwargs)
|
|
||||||
|
|
||||||
if not isinstance(result, dict):
|
|
||||||
return result
|
|
||||||
|
|
||||||
try:
|
|
||||||
if request.path.startswith('/inpage/'):
|
|
||||||
return result['inpage']()
|
|
||||||
elif request.path.startswith(('/api/vue/','/test/')):
|
|
||||||
return result['api']()
|
|
||||||
else:
|
|
||||||
return result['html']()
|
|
||||||
except KeyError:
|
|
||||||
return result
|
|
||||||
|
|
||||||
wrapper.__name__ = f.__name__
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
return wrapper_maker
|
|
|
@ -79,7 +79,7 @@ def activate(v):
|
||||||
if not validate_hash(f"{email}+{id}+{timestamp}", token):
|
if not validate_hash(f"{email}+{id}+{timestamp}", token):
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id=id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=id).first()
|
||||||
if not user:
|
if not user:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
@ -96,5 +96,6 @@ def activate(v):
|
||||||
g.db.add(mail_badge)
|
g.db.add(mail_badge)
|
||||||
|
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
g.db.commit()
|
||||||
|
|
||||||
return render_template("message_success.html", v=v, title="Email verified.", message=f"Your email {email} has been verified. Thank you.")
|
return render_template("message_success.html", v=v, title="Email verified.", message=f"Your email {email} has been verified. Thank you.")
|
||||||
|
|
|
@ -31,18 +31,18 @@ def revert_actions(v, username):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
|
|
||||||
items = g.db.query(Submission).options(lazyload('*')).filter_by(removed_by=user.id).all() + g.db.query(Comment).options(lazyload('*')).filter_by(removed_by=user.id).all()
|
items = g.db.query(Submission).options(lazyload('*')).options(lazyload('*')).filter_by(removed_by=user.id).all() + g.db.query(Comment).options(lazyload('*')).options(lazyload('*')).filter_by(removed_by=user.id).all()
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
item.is_banned = False
|
item.is_banned = False
|
||||||
item.removed_by = None
|
item.removed_by = None
|
||||||
g.db.add(item)
|
g.db.add(item)
|
||||||
|
|
||||||
users = g.db.query(User).options(lazyload('*')).filter_by(is_banned=user.id).all()
|
users = g.db.query(User).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=user.id).all()
|
||||||
for user in users:
|
for user in users:
|
||||||
user.unban()
|
user.unban()
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Admin actions reverted!"}
|
return {"message": "Admin actions reverted!"}
|
||||||
|
|
||||||
@app.post("/@<username>/club_allow")
|
@app.post("/@<username>/club_allow")
|
||||||
|
@ -97,7 +97,7 @@ def make_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 6
|
user.admin_level = 6
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "User has been made admin!"}
|
return {"message": "User has been made admin!"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ def remove_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 0
|
user.admin_level = 0
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Admin removed!"}
|
return {"message": "Admin removed!"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ def make_fake_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 1
|
user.admin_level = 1
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "User has been made fake admin!"}
|
return {"message": "User has been made fake admin!"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ def remove_fake_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 0
|
user.admin_level = 0
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Fake admin removed!"}
|
return {"message": "Fake admin removed!"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ def monthly(v):
|
||||||
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [1,12,28,29,747,995,1480]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
if 'pcm' in request.host or ('rdrama' in request.host and v.id in [1,12,28,29,747,995,1480]) or ('rdrama' not in request.host and 'pcm' not in request.host):
|
||||||
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
|
||||||
_awards = []
|
_awards = []
|
||||||
for u in g.db.query(User).filter(User.patron > 0).all():
|
for u in g.db.query(User).options(lazyload('*')).filter(User.patron > 0).all():
|
||||||
grant_awards = {}
|
grant_awards = {}
|
||||||
|
|
||||||
if u.patron == 1:
|
if u.patron == 1:
|
||||||
|
@ -224,7 +224,7 @@ def post_rules(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def shadowbanned(v):
|
def shadowbanned(v):
|
||||||
if not (v and v.admin_level == 6): abort(404)
|
if not (v and v.admin_level == 6): abort(404)
|
||||||
users = [x for x in g.db.query(User).filter_by(shadowbanned = True).all()]
|
users = [x for x in g.db.query(User).options(lazyload('*')).filter_by(shadowbanned = True).all()]
|
||||||
return render_template("banned.html", v=v, users=users)
|
return render_template("banned.html", v=v, users=users)
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ def shadowbanned(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def agendaposters(v):
|
def agendaposters(v):
|
||||||
if not (v and v.admin_level == 6): abort(404)
|
if not (v and v.admin_level == 6): abort(404)
|
||||||
users = [x for x in g.db.query(User).filter_by(agendaposter = True).all()]
|
users = [x for x in g.db.query(User).options(lazyload('*')).filter_by(agendaposter = True).all()]
|
||||||
return render_template("banned.html", v=v, users=users)
|
return render_template("banned.html", v=v, users=users)
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ def reported_posts(v):
|
||||||
|
|
||||||
page = max(1, int(request.args.get("page", 1)))
|
page = max(1, int(request.args.get("page", 1)))
|
||||||
|
|
||||||
posts = g.db.query(Submission).filter_by(
|
posts = g.db.query(Submission).options(lazyload('*')).filter_by(
|
||||||
is_approved=0,
|
is_approved=0,
|
||||||
is_banned=False
|
is_banned=False
|
||||||
).join(Submission.flags).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
).join(Submission.flags).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26)
|
||||||
|
@ -352,7 +352,7 @@ def badge_grant_post(v):
|
||||||
except: abort(400)
|
except: abort(400)
|
||||||
|
|
||||||
if user.has_badge(badge_id):
|
if user.has_badge(badge_id):
|
||||||
g.db.query(Badge).filter_by(badge_id=badge_id, user_id=user.id,).delete()
|
g.db.query(Badge).options(lazyload('*')).filter_by(badge_id=badge_id, user_id=user.id,).delete()
|
||||||
return redirect("/admin/badge_grant")
|
return redirect("/admin/badge_grant")
|
||||||
|
|
||||||
new_badge = Badge(badge_id=badge_id,
|
new_badge = Badge(badge_id=badge_id,
|
||||||
|
@ -376,7 +376,7 @@ def badge_grant_post(v):
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, user, text)
|
send_notification(NOTIFICATIONS_ACCOUNT, user, text)
|
||||||
|
|
||||||
if badge_id == 16 and user.has_badge(17):
|
if badge_id == 16 and user.has_badge(17):
|
||||||
g.db.query(Badge).filter_by(badge_id=17, user_id=user.id).delete()
|
g.db.query(Badge).options(lazyload('*')).filter_by(badge_id=17, user_id=user.id).delete()
|
||||||
|
|
||||||
elif badge_id in [21,22,23,24,28]:
|
elif badge_id in [21,22,23,24,28]:
|
||||||
user.patron = int(str(badge_id)[-1])
|
user.patron = int(str(badge_id)[-1])
|
||||||
|
@ -436,7 +436,7 @@ def badge_grant_post(v):
|
||||||
|
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return redirect("/admin/badge_grant")
|
return redirect("/admin/badge_grant")
|
||||||
|
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ def users_list(v):
|
||||||
|
|
||||||
page = int(request.args.get("page", 1))
|
page = int(request.args.get("page", 1))
|
||||||
|
|
||||||
users = g.db.query(User).filter_by(is_banned=0
|
users = g.db.query(User).options(lazyload('*')).filter_by(is_banned=0
|
||||||
).order_by(User.created_utc.desc()
|
).order_by(User.created_utc.desc()
|
||||||
).offset(25 * (page - 1)).limit(26)
|
).offset(25 * (page - 1)).limit(26)
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ def admin_removed(v):
|
||||||
|
|
||||||
page = int(request.args.get("page", 1))
|
page = int(request.args.get("page", 1))
|
||||||
|
|
||||||
ids = g.db.query(Submission.id).options(lazyload('*')).filter_by(is_banned=True).order_by(
|
ids = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=True).order_by(
|
||||||
Submission.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
Submission.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||||
|
|
||||||
ids=[x[0] for x in ids]
|
ids=[x[0] for x in ids]
|
||||||
|
@ -621,7 +621,7 @@ def admin_removed(v):
|
||||||
def admin_image_purge(v):
|
def admin_image_purge(v):
|
||||||
|
|
||||||
name = request.form.get("url")
|
name = request.form.get("url")
|
||||||
image = g.db.query(Image).filter(Image.text == name).first()
|
image = g.db.query(Image).options(lazyload('*')).filter(Image.text == name).first()
|
||||||
if image:
|
if image:
|
||||||
requests.delete(f'https://api.imgur.com/3/image/{image.deletehash}', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"})
|
requests.delete(f'https://api.imgur.com/3/image/{image.deletehash}', headers = {"Authorization": f"Client-ID {IMGUR_KEY}"})
|
||||||
headers = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/json"}
|
headers = {"Authorization": f"Bearer {CF_KEY}", "Content-Type": "application/json"}
|
||||||
|
@ -663,7 +663,7 @@ def admin_image_ban(v):
|
||||||
h = ''.join([str(d) for d in bindigits])
|
h = ''.join([str(d) for d in bindigits])
|
||||||
|
|
||||||
#check db for existing
|
#check db for existing
|
||||||
badpic = g.db.query(BadPic).filter_by(
|
badpic = g.db.query(BadPic).options(lazyload('*')).filter_by(
|
||||||
phash=h
|
phash=h
|
||||||
).first()
|
).first()
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ def admin_image_ban(v):
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def agendaposter(user_id, v):
|
def agendaposter(user_id, v):
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
|
|
||||||
expiry = request.form.get("days", 0)
|
expiry = request.form.get("days", 0)
|
||||||
if expiry:
|
if expiry:
|
||||||
|
@ -720,7 +720,6 @@ def agendaposter(user_id, v):
|
||||||
note = note
|
note = note
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
if user.agendaposter:
|
if user.agendaposter:
|
||||||
if not user.has_badge(26):
|
if not user.has_badge(26):
|
||||||
|
@ -741,7 +740,7 @@ def agendaposter(user_id, v):
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def shadowban(user_id, v):
|
def shadowban(user_id, v):
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
if user.admin_level != 0: abort(403)
|
if user.admin_level != 0: abort(403)
|
||||||
user.shadowbanned = True
|
user.shadowbanned = True
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
@ -766,7 +765,7 @@ def shadowban(user_id, v):
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def unshadowban(user_id, v):
|
def unshadowban(user_id, v):
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
if user.admin_level != 0: abort(403)
|
if user.admin_level != 0: abort(403)
|
||||||
user.shadowbanned = False
|
user.shadowbanned = False
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
@ -790,7 +789,7 @@ def unshadowban(user_id, v):
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def verify(user_id, v):
|
def verify(user_id, v):
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
user.verified = "Verified"
|
user.verified = "Verified"
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -800,7 +799,7 @@ def verify(user_id, v):
|
||||||
@admin_level_required(6)
|
@admin_level_required(6)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def unverify(user_id, v):
|
def unverify(user_id, v):
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
user.verified = None
|
user.verified = None
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -812,7 +811,7 @@ def unverify(user_id, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def admin_title_change(user_id, v):
|
def admin_title_change(user_id, v):
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
|
|
||||||
if user.admin_level != 0: abort(403)
|
if user.admin_level != 0: abort(403)
|
||||||
|
|
||||||
|
@ -821,7 +820,7 @@ def admin_title_change(user_id, v):
|
||||||
user.customtitleplain=new_name
|
user.customtitleplain=new_name
|
||||||
new_name = sanitize(new_name)
|
new_name = sanitize(new_name)
|
||||||
|
|
||||||
user=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=user.id).first()
|
user=g.db.query(User).with_for_update().options(lazyload('*')).options(lazyload('*')).filter_by(id=user.id).first()
|
||||||
user.customtitle=new_name
|
user.customtitle=new_name
|
||||||
user.flairchanged = bool(request.form.get("locked"))
|
user.flairchanged = bool(request.form.get("locked"))
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
@ -845,7 +844,7 @@ def admin_title_change(user_id, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def ban_user(user_id, v):
|
def ban_user(user_id, v):
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
|
|
||||||
if user.admin_level >= v.admin_level: abort(403)
|
if user.admin_level >= v.admin_level: abort(403)
|
||||||
|
|
||||||
|
@ -896,8 +895,6 @@ def ban_user(user_id, v):
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
|
||||||
|
|
||||||
if 'reason' in request.args:
|
if 'reason' in request.args:
|
||||||
if reason.startswith("/post/"):
|
if reason.startswith("/post/"):
|
||||||
post = reason.split("/post/")[1].split("/")[0]
|
post = reason.split("/post/")[1].split("/")[0]
|
||||||
|
@ -909,8 +906,11 @@ def ban_user(user_id, v):
|
||||||
comment = get_comment(comment)
|
comment = get_comment(comment)
|
||||||
comment.bannedfor = True
|
comment.bannedfor = True
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
|
g.db.commit()
|
||||||
return {"message": f"@{user.username} was banned!"}
|
return {"message": f"@{user.username} was banned!"}
|
||||||
else: return redirect(user.url)
|
else:
|
||||||
|
g.db.commit()
|
||||||
|
return redirect(user.url)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/unban_user/<user_id>")
|
@app.post("/unban_user/<user_id>")
|
||||||
|
@ -918,7 +918,7 @@ def ban_user(user_id, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def unban_user(user_id, v):
|
def unban_user(user_id, v):
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
@ -942,17 +942,15 @@ def unban_user(user_id, v):
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
if "@" in request.referrer:
|
if "@" in request.referrer: return redirect(user.url)
|
||||||
return redirect(user.url)
|
else: return {"message": f"@{user.username} was unbanned!"}
|
||||||
else:
|
|
||||||
return {"message": f"@{user.username} was unbanned!"}
|
|
||||||
|
|
||||||
@app.post("/ban_post/<post_id>")
|
@app.post("/ban_post/<post_id>")
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def ban_post(post_id, v):
|
def ban_post(post_id, v):
|
||||||
|
|
||||||
post = g.db.query(Submission).filter_by(id=post_id).first()
|
post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first()
|
||||||
|
|
||||||
if not post:
|
if not post:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
@ -993,7 +991,7 @@ def ban_post(post_id, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def unban_post(post_id, v):
|
def unban_post(post_id, v):
|
||||||
|
|
||||||
post = g.db.query(Submission).filter_by(id=post_id).first()
|
post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first()
|
||||||
|
|
||||||
if not post:
|
if not post:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
@ -1023,7 +1021,7 @@ def unban_post(post_id, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def api_distinguish_post(post_id, v):
|
def api_distinguish_post(post_id, v):
|
||||||
|
|
||||||
post = g.db.query(Submission).filter_by(id=post_id).first()
|
post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first()
|
||||||
|
|
||||||
if not post:
|
if not post:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
@ -1047,7 +1045,7 @@ def api_distinguish_post(post_id, v):
|
||||||
@admin_level_required(3)
|
@admin_level_required(3)
|
||||||
def api_sticky_post(post_id, v):
|
def api_sticky_post(post_id, v):
|
||||||
|
|
||||||
post = g.db.query(Submission).filter_by(id=post_id).first()
|
post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first()
|
||||||
if post:
|
if post:
|
||||||
post.stickied = not (post.stickied)
|
post.stickied = not (post.stickied)
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
@ -1069,7 +1067,7 @@ def api_sticky_post(post_id, v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def api_pin_post(post_id, v):
|
def api_pin_post(post_id, v):
|
||||||
|
|
||||||
post = g.db.query(Submission).filter_by(id=post_id).first()
|
post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first()
|
||||||
if post:
|
if post:
|
||||||
post.is_pinned = not (post.is_pinned)
|
post.is_pinned = not (post.is_pinned)
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
@ -1082,7 +1080,7 @@ def api_pin_post(post_id, v):
|
||||||
@admin_level_required(1)
|
@admin_level_required(1)
|
||||||
def api_ban_comment(c_id, v):
|
def api_ban_comment(c_id, v):
|
||||||
|
|
||||||
comment = g.db.query(Comment).filter_by(id=c_id).first()
|
comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=c_id).first()
|
||||||
if not comment:
|
if not comment:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
@ -1105,7 +1103,7 @@ def api_ban_comment(c_id, v):
|
||||||
@admin_level_required(1)
|
@admin_level_required(1)
|
||||||
def api_unban_comment(c_id, v):
|
def api_unban_comment(c_id, v):
|
||||||
|
|
||||||
comment = g.db.query(Comment).filter_by(id=c_id).first()
|
comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=c_id).first()
|
||||||
if not comment:
|
if not comment:
|
||||||
abort(404)
|
abort(404)
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
|
@ -1177,7 +1175,7 @@ def admin_toggle_ban_domain(v):
|
||||||
|
|
||||||
reason=request.form.get("reason", "").strip()
|
reason=request.form.get("reason", "").strip()
|
||||||
|
|
||||||
d = g.db.query(BannedDomain).filter_by(domain=domain).first()
|
d = g.db.query(BannedDomain).options(lazyload('*')).filter_by(domain=domain).first()
|
||||||
if d: g.db.delete(d)
|
if d: g.db.delete(d)
|
||||||
else:
|
else:
|
||||||
d = BannedDomain(domain=domain, reason=reason)
|
d = BannedDomain(domain=domain, reason=reason)
|
||||||
|
@ -1195,14 +1193,14 @@ def admin_nuke_user(v):
|
||||||
|
|
||||||
user=get_user(request.form.get("user"))
|
user=get_user(request.form.get("user"))
|
||||||
|
|
||||||
for post in g.db.query(Submission).filter_by(author_id=user.id).all():
|
for post in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=user.id).all():
|
||||||
if post.is_banned:
|
if post.is_banned:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
post.is_banned=True
|
post.is_banned=True
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
for comment in g.db.query(Comment).filter_by(author_id=user.id).all():
|
for comment in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=user.id).all():
|
||||||
if comment.is_banned:
|
if comment.is_banned:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1227,14 +1225,14 @@ def admin_nunuke_user(v):
|
||||||
|
|
||||||
user=get_user(request.form.get("user"))
|
user=get_user(request.form.get("user"))
|
||||||
|
|
||||||
for post in g.db.query(Submission).filter_by(author_id=user.id).all():
|
for post in g.db.query(Submission).options(lazyload('*')).filter_by(author_id=user.id).all():
|
||||||
if not post.is_banned:
|
if not post.is_banned:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
post.is_banned=False
|
post.is_banned=False
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
for comment in g.db.query(Comment).filter_by(author_id=user.id).all():
|
for comment in g.db.query(Comment).options(lazyload('*')).filter_by(author_id=user.id).all():
|
||||||
if not comment.is_banned:
|
if not comment.is_banned:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1278,11 +1276,11 @@ def chart(v):
|
||||||
|
|
||||||
daily_times = [time.strftime("%d", time.gmtime(day_cutoffs[i + 1])) for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
daily_times = [time.strftime("%d", time.gmtime(day_cutoffs[i + 1])) for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
||||||
|
|
||||||
daily_signups = [g.db.query(User).filter(User.created_utc < day_cutoffs[i], User.created_utc > day_cutoffs[i + 1]).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
daily_signups = [g.db.query(User).options(lazyload('*')).filter(User.created_utc < day_cutoffs[i], User.created_utc > day_cutoffs[i + 1]).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
||||||
|
|
||||||
post_stats = [g.db.query(Submission).filter(Submission.created_utc < day_cutoffs[i], Submission.created_utc > day_cutoffs[i + 1], Submission.is_banned == False).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
post_stats = [g.db.query(Submission).options(lazyload('*')).filter(Submission.created_utc < day_cutoffs[i], Submission.created_utc > day_cutoffs[i + 1], Submission.is_banned == False).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
||||||
|
|
||||||
comment_stats = [g.db.query(Comment).filter(Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1],Comment.is_banned == False, Comment.author_id != 1).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
comment_stats = [g.db.query(Comment).options(lazyload('*')).filter(Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1],Comment.is_banned == False, Comment.author_id != 1).count() for i in range(len(day_cutoffs) - 1)][2:][::-1]
|
||||||
|
|
||||||
# create multiple charts
|
# create multiple charts
|
||||||
signup_chart = plt.subplot2grid((20, 4), (0, 0), rowspan=5, colspan=4)
|
signup_chart = plt.subplot2grid((20, 4), (0, 0), rowspan=5, colspan=4)
|
||||||
|
|
|
@ -7,6 +7,7 @@ from files.classes.award import *
|
||||||
from flask import g, request
|
from flask import g, request
|
||||||
|
|
||||||
@app.get("/shop")
|
@app.get("/shop")
|
||||||
|
@app.get("/settings/shop")
|
||||||
@auth_required
|
@auth_required
|
||||||
def shop(v):
|
def shop(v):
|
||||||
if site_name == "Drama":
|
if site_name == "Drama":
|
||||||
|
@ -80,7 +81,22 @@ def shop(v):
|
||||||
elif v.patron == 4: val["price"] = int(val["price"]*0.75)
|
elif v.patron == 4: val["price"] = int(val["price"]*0.75)
|
||||||
else: val["price"] = int(val["price"]*0.70)
|
else: val["price"] = int(val["price"]*0.70)
|
||||||
|
|
||||||
return render_template("shop.html", owned=owned, awards=list(AWARDS.values()), v=v)
|
return render_template("settings_shop.html", owned=owned, awards=list(AWARDS.values()), v=v)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/awards")
|
||||||
|
@auth_required
|
||||||
|
def get_awards(v):
|
||||||
|
|
||||||
|
return_value = list(AWARDS.values())
|
||||||
|
|
||||||
|
user_awards = v.awards
|
||||||
|
for val in return_value:
|
||||||
|
val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count()
|
||||||
|
|
||||||
|
return jsonify(return_value)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/buy/<award>")
|
@app.post("/buy/<award>")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
@ -182,20 +198,6 @@ ALLOW_MULTIPLE = (
|
||||||
"stars"
|
"stars"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/awards")
|
|
||||||
@auth_required
|
|
||||||
def get_awards(v):
|
|
||||||
|
|
||||||
return_value = list(AWARDS.values())
|
|
||||||
|
|
||||||
user_awards = v.awards
|
|
||||||
for val in return_value:
|
|
||||||
val['owned'] = len([x for x in user_awards if x.kind == val['kind'] and not x.given])
|
|
||||||
|
|
||||||
return jsonify(return_value)
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/post/<pid>/awards")
|
@app.post("/post/<pid>/awards")
|
||||||
@auth_required
|
@auth_required
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
|
@ -209,7 +211,7 @@ def award_post(pid, v):
|
||||||
if kind not in AWARDS:
|
if kind not in AWARDS:
|
||||||
return {"error": "That award doesn't exist."}, 404
|
return {"error": "That award doesn't exist."}, 404
|
||||||
|
|
||||||
post_award = g.db.query(AwardRelationship).filter(
|
post_award = g.db.query(AwardRelationship).options(lazyload('*')).filter(
|
||||||
and_(
|
and_(
|
||||||
AwardRelationship.kind == kind,
|
AwardRelationship.kind == kind,
|
||||||
AwardRelationship.user_id == v.id,
|
AwardRelationship.user_id == v.id,
|
||||||
|
@ -221,7 +223,7 @@ def award_post(pid, v):
|
||||||
if not post_award:
|
if not post_award:
|
||||||
return {"error": "You don't have that award."}, 404
|
return {"error": "You don't have that award."}, 404
|
||||||
|
|
||||||
post = g.db.query(Submission).filter_by(id=pid).first()
|
post = g.db.query(Submission).options(lazyload('*')).filter_by(id=pid).first()
|
||||||
|
|
||||||
if not post or post.is_banned or post.deleted_utc > 0:
|
if not post or post.is_banned or post.deleted_utc > 0:
|
||||||
return {"error": "That post doesn't exist or has been deleted or removed."}, 404
|
return {"error": "That post doesn't exist or has been deleted or removed."}, 404
|
||||||
|
@ -229,7 +231,7 @@ def award_post(pid, v):
|
||||||
if post.author_id == v.id:
|
if post.author_id == v.id:
|
||||||
return {"error": "You can't award yourself."}, 403
|
return {"error": "You can't award yourself."}, 403
|
||||||
|
|
||||||
existing_award = g.db.query(AwardRelationship).filter(
|
existing_award = g.db.query(AwardRelationship).options(lazyload('*')).filter(
|
||||||
and_(
|
and_(
|
||||||
AwardRelationship.submission_id == post.id,
|
AwardRelationship.submission_id == post.id,
|
||||||
AwardRelationship.user_id == v.id,
|
AwardRelationship.user_id == v.id,
|
||||||
|
@ -252,8 +254,7 @@ def award_post(pid, v):
|
||||||
|
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, post.author, msg)
|
send_notification(NOTIFICATIONS_ACCOUNT, post.author, msg)
|
||||||
|
|
||||||
if kind in ACTIONS:
|
if kind in ACTIONS: ACTIONS[kind](post=post)
|
||||||
ACTIONS[kind](post=post)
|
|
||||||
|
|
||||||
post.author.received_award_count += 1
|
post.author.received_award_count += 1
|
||||||
g.db.add(post.author)
|
g.db.add(post.author)
|
||||||
|
@ -275,7 +276,7 @@ def award_comment(cid, v):
|
||||||
if kind not in AWARDS:
|
if kind not in AWARDS:
|
||||||
return {"error": "That award doesn't exist."}, 404
|
return {"error": "That award doesn't exist."}, 404
|
||||||
|
|
||||||
comment_award = g.db.query(AwardRelationship).filter(
|
comment_award = g.db.query(AwardRelationship).options(lazyload('*')).filter(
|
||||||
and_(
|
and_(
|
||||||
AwardRelationship.kind == kind,
|
AwardRelationship.kind == kind,
|
||||||
AwardRelationship.user_id == v.id,
|
AwardRelationship.user_id == v.id,
|
||||||
|
@ -287,7 +288,7 @@ def award_comment(cid, v):
|
||||||
if not comment_award:
|
if not comment_award:
|
||||||
return {"error": "You don't have that award."}, 404
|
return {"error": "You don't have that award."}, 404
|
||||||
|
|
||||||
c = g.db.query(Comment).filter_by(id=cid).first()
|
c = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first()
|
||||||
|
|
||||||
if not c or c.is_banned or c.deleted_utc > 0:
|
if not c or c.is_banned or c.deleted_utc > 0:
|
||||||
return {"error": "That comment doesn't exist or has been deleted or removed."}, 404
|
return {"error": "That comment doesn't exist or has been deleted or removed."}, 404
|
||||||
|
@ -295,7 +296,7 @@ def award_comment(cid, v):
|
||||||
if c.author_id == v.id:
|
if c.author_id == v.id:
|
||||||
return {"error": "You can't award yourself."}, 403
|
return {"error": "You can't award yourself."}, 403
|
||||||
|
|
||||||
existing_award = g.db.query(AwardRelationship).filter(
|
existing_award = g.db.query(AwardRelationship).options(lazyload('*')).filter(
|
||||||
and_(
|
and_(
|
||||||
AwardRelationship.comment_id == c.id,
|
AwardRelationship.comment_id == c.id,
|
||||||
AwardRelationship.user_id == v.id,
|
AwardRelationship.user_id == v.id,
|
||||||
|
|
|
@ -82,7 +82,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
post.replies=[top_comment]
|
post.replies=[top_comment]
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ def api_comment(v):
|
||||||
return {"error": reason}, 401
|
return {"error": reason}, 401
|
||||||
|
|
||||||
# check existing
|
# check existing
|
||||||
existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
Comment.parent_comment_id == parent_comment_id,
|
Comment.parent_comment_id == parent_comment_id,
|
||||||
Comment.parent_submission == parent_submission,
|
Comment.parent_submission == parent_submission,
|
||||||
|
@ -260,7 +260,7 @@ def api_comment(v):
|
||||||
fragment='')
|
fragment='')
|
||||||
check_url = urlunparse(check_url)
|
check_url = urlunparse(check_url)
|
||||||
|
|
||||||
badlink = g.db.query(BadLink).filter(
|
badlink = g.db.query(BadLink).options(lazyload('*')).filter(
|
||||||
literal(check_url).contains(
|
literal(check_url).contains(
|
||||||
BadLink.link)).first()
|
BadLink.link)).first()
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ def api_comment(v):
|
||||||
# queue up notification for parent author
|
# queue up notification for parent author
|
||||||
notify_users = set()
|
notify_users = set()
|
||||||
|
|
||||||
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all():
|
for x in g.db.query(Subscription.user_id).options(lazyload('*')).filter_by(submission_id=c.parent_submission).all():
|
||||||
notify_users.add(x[0])
|
notify_users.add(x[0])
|
||||||
|
|
||||||
if parent.author.id != v.id: notify_users.add(parent.author.id)
|
if parent.author.id != v.id: notify_users.add(parent.author.id)
|
||||||
|
@ -537,7 +537,7 @@ def api_comment(v):
|
||||||
for mention in mentions:
|
for mention in mentions:
|
||||||
username = mention["href"].split("@")[1]
|
username = mention["href"].split("@")[1]
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first()
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
if v.any_block_exists(user):
|
if v.any_block_exists(user):
|
||||||
|
@ -581,7 +581,7 @@ def api_comment(v):
|
||||||
v.comment_count = v.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count()
|
v.comment_count = v.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count()
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
parent_post.comment_count = g.db.query(Comment).filter_by(parent_submission=parent_post.id).count()
|
parent_post.comment_count = g.db.query(Comment).options(lazyload('*')).filter_by(parent_submission=parent_post.id).count()
|
||||||
g.db.add(parent_post)
|
g.db.add(parent_post)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -650,7 +650,7 @@ def edit_comment(cid, v):
|
||||||
fragment='')
|
fragment='')
|
||||||
check_url = urlunparse(check_url)
|
check_url = urlunparse(check_url)
|
||||||
|
|
||||||
badlink = g.db.query(BadLink).filter(
|
badlink = g.db.query(BadLink).options(lazyload('*')).filter(
|
||||||
literal(check_url).contains(
|
literal(check_url).contains(
|
||||||
BadLink.link)).first()
|
BadLink.link)).first()
|
||||||
|
|
||||||
|
@ -795,7 +795,7 @@ def edit_comment(cid, v):
|
||||||
for mention in mentions:
|
for mention in mentions:
|
||||||
username = mention["href"].split("@")[1]
|
username = mention["href"].split("@")[1]
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first()
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
if v.any_block_exists(user):
|
if v.any_block_exists(user):
|
||||||
|
@ -819,7 +819,7 @@ def edit_comment(cid, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def delete_comment(cid, v):
|
def delete_comment(cid, v):
|
||||||
|
|
||||||
c = g.db.query(Comment).filter_by(id=cid).first()
|
c = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first()
|
||||||
|
|
||||||
if not c:
|
if not c:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
@ -842,7 +842,7 @@ def delete_comment(cid, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def undelete_comment(cid, v):
|
def undelete_comment(cid, v):
|
||||||
|
|
||||||
c = g.db.query(Comment).filter_by(id=cid).first()
|
c = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first()
|
||||||
|
|
||||||
if not c:
|
if not c:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
@ -912,7 +912,7 @@ def unsave_comment(cid, v):
|
||||||
|
|
||||||
comment=get_comment(cid)
|
comment=get_comment(cid)
|
||||||
|
|
||||||
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=comment.id, type=2).first()
|
save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=comment.id, type=2).first()
|
||||||
|
|
||||||
if save: g.db.delete(save)
|
if save: g.db.delete(save)
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ def discord_redirect(v):
|
||||||
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}"
|
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}"
|
||||||
requests.delete(url, headers=headers)
|
requests.delete(url, headers=headers)
|
||||||
|
|
||||||
if g.db.query(User).filter(User.id!=v.id, User.discord_id==x["id"]).first():
|
if g.db.query(User).options(lazyload('*')).filter(User.id!=v.id, User.discord_id==x["id"]).first():
|
||||||
return render_template("message.html", title="Discord account already linked.", error="That Discord account is already in use by another user.", v=v)
|
return render_template("message.html", title="Discord account already linked.", error="That Discord account is already in use by another user.", v=v)
|
||||||
|
|
||||||
v.discord_id=x["id"]
|
v.discord_id=x["id"]
|
||||||
|
|
|
@ -10,8 +10,6 @@ defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "all").strip()
|
||||||
def slash_post():
|
def slash_post():
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
# this is a test
|
|
||||||
|
|
||||||
@app.get("/notifications")
|
@app.get("/notifications")
|
||||||
@auth_required
|
@auth_required
|
||||||
def notifications(v):
|
def notifications(v):
|
||||||
|
@ -21,35 +19,34 @@ def notifications(v):
|
||||||
modmail = request.args.get('modmail', False)
|
modmail = request.args.get('modmail', False)
|
||||||
posts = request.args.get('posts', False)
|
posts = request.args.get('posts', False)
|
||||||
if modmail and v.admin_level == 6:
|
if modmail and v.admin_level == 6:
|
||||||
comments = g.db.query(Comment).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all()
|
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.sentto==0).order_by(Comment.created_utc.desc()).offset(25*(page-1)).limit(26).all()
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
comments = comments[:25]
|
comments = comments[:25]
|
||||||
elif messages:
|
elif messages:
|
||||||
comments = g.db.query(Comment).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
|
comments = g.db.query(Comment).options(lazyload('*')).filter(or_(Comment.author_id==v.id, Comment.sentto==v.id), Comment.parent_submission == None).order_by(Comment.created_utc.desc(), not_(Comment.child_comments.any())).offset(25*(page-1)).limit(26).all()
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
comments = comments[:25]
|
comments = comments[:25]
|
||||||
elif posts:
|
elif posts:
|
||||||
notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
notifications = v.notifications.options(lazyload('*')).join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||||
|
|
||||||
comments = []
|
comments = []
|
||||||
notifs = []
|
|
||||||
|
|
||||||
for index, x in enumerate(notifications):
|
for index, x in enumerate(notifications):
|
||||||
c = x.comment
|
c = x.comment
|
||||||
if x.read and index > 26: break
|
if x.read and index > 26: break
|
||||||
elif not x.read:
|
elif not x.read:
|
||||||
c.unread = True
|
c.unread = True
|
||||||
notifs.append({'id': x.id, 'read': True})
|
x.read = True
|
||||||
|
g.db.add(x)
|
||||||
comments.append(c)
|
comments.append(c)
|
||||||
|
|
||||||
g.db.bulk_update_mappings(Notification, notifs)
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
next_exists = (len(comments) > 25)
|
next_exists = (len(comments) > 25)
|
||||||
listing = comments[:25]
|
listing = comments[:25]
|
||||||
else:
|
else:
|
||||||
|
|
||||||
notifications = v.notifications.join(Notification.comment).filter(
|
notifications = v.notifications.options(lazyload('*')).join(Notification.comment).filter(
|
||||||
Comment.is_banned == False,
|
Comment.is_banned == False,
|
||||||
Comment.deleted_utc == 0,
|
Comment.deleted_utc == 0,
|
||||||
Comment.author_id != AUTOJANNY_ACCOUNT,
|
Comment.author_id != AUTOJANNY_ACCOUNT,
|
||||||
|
@ -60,16 +57,16 @@ def notifications(v):
|
||||||
cids = [x.comment_id for x in notifications]
|
cids = [x.comment_id for x in notifications]
|
||||||
comments = get_comments(cids, v=v, load_parent=True)
|
comments = get_comments(cids, v=v, load_parent=True)
|
||||||
|
|
||||||
notifs = []
|
|
||||||
i = 0
|
i = 0
|
||||||
for x in notifications:
|
for x in notifications:
|
||||||
try:
|
try:
|
||||||
if not x.read: comments[i].unread = True
|
if not x.read:
|
||||||
|
comments[i].unread = True
|
||||||
|
x.read = True
|
||||||
|
g.db.add(x)
|
||||||
except: continue
|
except: continue
|
||||||
notifs.append({'id': x.id, 'read': True})
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
g.db.bulk_update_mappings(Notification, notifs)
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
if not posts:
|
if not posts:
|
||||||
|
@ -139,12 +136,12 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
||||||
posts = posts.filter_by(processing=False)
|
posts = posts.filter_by(processing=False)
|
||||||
|
|
||||||
if v and v.admin_level == 0:
|
if v and v.admin_level == 0:
|
||||||
blocking = g.db.query(
|
blocking = [x[0] for x in g.db.query(
|
||||||
UserBlock.target_id).filter_by(
|
UserBlock.target_id).filter_by(
|
||||||
user_id=v.id).subquery()
|
user_id=v.id).all()]
|
||||||
blocked = g.db.query(
|
blocked = [x[0] for x in g.db.query(
|
||||||
UserBlock.user_id).filter_by(
|
UserBlock.user_id).filter_by(
|
||||||
target_id=v.id).subquery()
|
target_id=v.id).all()]
|
||||||
posts = posts.filter(
|
posts = posts.filter(
|
||||||
Submission.author_id.notin_(blocking),
|
Submission.author_id.notin_(blocking),
|
||||||
Submission.author_id.notin_(blocked)
|
Submission.author_id.notin_(blocked)
|
||||||
|
@ -206,8 +203,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
||||||
# g.db.add(vote)
|
# g.db.add(vote)
|
||||||
# try: g.db.flush()
|
# try: g.db.flush()
|
||||||
# except: g.db.rollback()
|
# except: g.db.rollback()
|
||||||
# post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count()
|
# post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count()
|
||||||
# post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count()
|
# post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count()
|
||||||
# post.views = post.views + random.randint(7,10)
|
# post.views = post.views + random.randint(7,10)
|
||||||
# g.db.add(post)
|
# g.db.add(post)
|
||||||
|
|
||||||
|
@ -215,7 +212,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
||||||
|
|
||||||
posts = posts[:25]
|
posts = posts[:25]
|
||||||
|
|
||||||
if page == 1: posts = g.db.query(Submission).filter_by(stickied=True).all() + posts
|
if page == 1: posts = g.db.query(Submission).options(lazyload('*')).filter_by(stickied=True).all() + posts
|
||||||
|
|
||||||
if ids_only: posts = [x.id for x in posts]
|
if ids_only: posts = [x.id for x in posts]
|
||||||
|
|
||||||
|
@ -268,15 +265,15 @@ def front_all(v):
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs):
|
def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs):
|
||||||
|
|
||||||
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False, private=False,).filter(Submission.deleted_utc == 0)
|
posts = g.db.query(Submission).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, private=False,).filter(Submission.deleted_utc == 0)
|
||||||
|
|
||||||
if v and v.admin_level == 0:
|
if v and v.admin_level == 0:
|
||||||
blocking = g.db.query(
|
blocking = [x[0] for x in g.db.query(
|
||||||
UserBlock.target_id).filter_by(
|
UserBlock.target_id).filter_by(
|
||||||
user_id=v.id).subquery()
|
user_id=v.id).all()]
|
||||||
blocked = g.db.query(
|
blocked = [x[0] for x in g.db.query(
|
||||||
UserBlock.user_id).filter_by(
|
UserBlock.user_id).filter_by(
|
||||||
target_id=v.id).subquery()
|
target_id=v.id).all()]
|
||||||
posts = posts.filter(
|
posts = posts.filter(
|
||||||
Submission.author_id.notin_(blocking),
|
Submission.author_id.notin_(blocking),
|
||||||
Submission.author_id.notin_(blocked)
|
Submission.author_id.notin_(blocked)
|
||||||
|
@ -370,7 +367,7 @@ def changelog(v):
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def random_post(v):
|
def random_post(v):
|
||||||
|
|
||||||
x = g.db.query(Submission).filter(Submission.deleted_utc == 0, Submission.is_banned == False)
|
x = g.db.query(Submission).options(lazyload('*')).filter(Submission.deleted_utc == 0, Submission.is_banned == False)
|
||||||
total = x.count()
|
total = x.count()
|
||||||
n = random.randint(1, total - 2)
|
n = random.randint(1, total - 2)
|
||||||
|
|
||||||
|
@ -381,19 +378,19 @@ def random_post(v):
|
||||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs):
|
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", **kwargs):
|
||||||
|
|
||||||
posts = g.db.query(Submission).options(lazyload('*'))
|
posts = g.db.query(Submission).options(lazyload('*'))
|
||||||
cc_idlist = g.db.query(Submission.id).filter(Submission.club == True).subquery()
|
cc_idlist = [x[0] for x in g.db.query(Submission.id).options(lazyload('*')).filter(Submission.club == True).all()]
|
||||||
|
|
||||||
posts = posts.subquery()
|
posts = posts.subquery()
|
||||||
|
|
||||||
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission.notin_(cc_idlist))
|
comments = g.db.query(Comment).options(lazyload('*')).options(lazyload('*')).filter(Comment.parent_submission.notin_(cc_idlist))
|
||||||
|
|
||||||
if v and v.admin_level <= 3:
|
if v and v.admin_level <= 3:
|
||||||
blocking = g.db.query(
|
blocking = [x[0] for x in g.db.query(
|
||||||
UserBlock.target_id).filter_by(
|
UserBlock.target_id).filter_by(
|
||||||
user_id=v.id).subquery()
|
user_id=v.id).all()]
|
||||||
blocked = g.db.query(
|
blocked = [x[0] for x in g.db.query(
|
||||||
UserBlock.user_id).filter_by(
|
UserBlock.user_id).filter_by(
|
||||||
target_id=v.id).subquery()
|
target_id=v.id).all()]
|
||||||
|
|
||||||
comments = comments.filter(
|
comments = comments.filter(
|
||||||
Comment.author_id.notin_(blocking),
|
Comment.author_id.notin_(blocking),
|
||||||
|
|
|
@ -9,7 +9,7 @@ GIPHY_KEY = environ.get('GIPHY_KEY').rstrip()
|
||||||
|
|
||||||
@app.route("/giphy", methods=["GET"])
|
@app.route("/giphy", methods=["GET"])
|
||||||
@app.route("/giphy<path>", methods=["GET"])
|
@app.route("/giphy<path>", methods=["GET"])
|
||||||
def giphy():
|
def giphy(path=None):
|
||||||
|
|
||||||
searchTerm = request.args.get("searchTerm", "")
|
searchTerm = request.args.get("searchTerm", "")
|
||||||
limit = int(request.args.get("limit", 48))
|
limit = int(request.args.get("limit", 48))
|
||||||
|
@ -19,4 +19,4 @@ def giphy():
|
||||||
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
|
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
|
||||||
else:
|
else:
|
||||||
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
|
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
|
||||||
return jsonify(requests.get(url).json())
|
return jsonify(requests.get(url).json())
|
||||||
|
|
|
@ -32,9 +32,9 @@ def check_for_alts(current_id):
|
||||||
if past_id == current_id:
|
if past_id == current_id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
check1 = g.db.query(Alt).filter_by(
|
check1 = g.db.query(Alt).options(lazyload('*')).filter_by(
|
||||||
user1=current_id, user2=past_id).first()
|
user1=current_id, user2=past_id).first()
|
||||||
check2 = g.db.query(Alt).filter_by(
|
check2 = g.db.query(Alt).options(lazyload('*')).filter_by(
|
||||||
user1=past_id, user2=current_id).first()
|
user1=past_id, user2=current_id).first()
|
||||||
|
|
||||||
if not check1 and not check2:
|
if not check1 and not check2:
|
||||||
|
@ -45,7 +45,7 @@ def check_for_alts(current_id):
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
otheralts = g.db.query(Alt).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
|
otheralts = g.db.query(Alt).options(lazyload('*')).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
|
||||||
for a in otheralts:
|
for a in otheralts:
|
||||||
new_alt = Alt(user1=a.user1, user2=past_id)
|
new_alt = Alt(user1=a.user1, user2=past_id)
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
@ -70,7 +70,7 @@ def login_post():
|
||||||
|
|
||||||
if not username: abort(400)
|
if not username: abort(400)
|
||||||
if "@" in username:
|
if "@" in username:
|
||||||
account = g.db.query(User).filter(
|
account = g.db.query(User).options(lazyload('*')).filter(
|
||||||
User.email.ilike(username)).first()
|
User.email.ilike(username)).first()
|
||||||
else:
|
else:
|
||||||
account = get_user(username, graceful=True)
|
account = get_user(username, graceful=True)
|
||||||
|
@ -174,7 +174,7 @@ def sign_up_get(v):
|
||||||
# check for referral in link
|
# check for referral in link
|
||||||
ref = request.args.get("ref", None)
|
ref = request.args.get("ref", None)
|
||||||
if ref:
|
if ref:
|
||||||
ref_user = g.db.query(User).filter(User.username.ilike(ref)).first()
|
ref_user = g.db.query(User).options(lazyload('*')).filter(User.username.ilike(ref)).first()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ref_user = None
|
ref_user = None
|
||||||
|
@ -247,7 +247,7 @@ def sign_up_post(v):
|
||||||
|
|
||||||
args = {"error": error}
|
args = {"error": error}
|
||||||
if request.form.get("referred_by"):
|
if request.form.get("referred_by"):
|
||||||
user = g.db.query(User).filter_by(
|
user = g.db.query(User).options(lazyload('*')).filter_by(
|
||||||
id=request.form.get("referred_by")).first()
|
id=request.form.get("referred_by")).first()
|
||||||
if user:
|
if user:
|
||||||
args["ref"] = user.username
|
args["ref"] = user.username
|
||||||
|
@ -318,7 +318,7 @@ def sign_up_post(v):
|
||||||
lazyload('*')).filter_by(id=ref_id).first()
|
lazyload('*')).filter_by(id=ref_id).first()
|
||||||
if ref_user:
|
if ref_user:
|
||||||
# check self-setting badges
|
# check self-setting badges
|
||||||
badge_types = g.db.query(BadgeDef).filter(BadgeDef.qualification_expr.isnot(None)).all()
|
badge_types = g.db.query(BadgeDef).options(lazyload('*')).filter(BadgeDef.qualification_expr.isnot(None)).all()
|
||||||
for badge in badge_types:
|
for badge in badge_types:
|
||||||
if eval(badge.qualification_expr, {}, {'v': ref_user}):
|
if eval(badge.qualification_expr, {}, {'v': ref_user}):
|
||||||
if not ref_user.has_badge(badge.id):
|
if not ref_user.has_badge(badge.id):
|
||||||
|
@ -330,7 +330,7 @@ def sign_up_post(v):
|
||||||
|
|
||||||
g.db.add(ref_user)
|
g.db.add(ref_user)
|
||||||
|
|
||||||
id_1 = g.db.query(User).filter_by(id=6).count()
|
id_1 = g.db.query(User).options(lazyload('*')).filter_by(id=6).count()
|
||||||
users_count = g.db.query(User).count() #paranoid
|
users_count = g.db.query(User).count() #paranoid
|
||||||
if id_1 == 0 and users_count < 6: admin_level=6
|
if id_1 == 0 and users_count < 6: admin_level=6
|
||||||
else: admin_level=0
|
else: admin_level=0
|
||||||
|
@ -344,9 +344,9 @@ def sign_up_post(v):
|
||||||
email=email,
|
email=email,
|
||||||
created_utc=int(time.time()),
|
created_utc=int(time.time()),
|
||||||
referred_by=ref_id or None,
|
referred_by=ref_id or None,
|
||||||
ban_evade = int(any([x.is_banned and not x.unban_utc for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])),
|
ban_evade = int(any([x.is_banned and not x.unban_utc for x in g.db.query(User).options(lazyload('*')).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])),
|
||||||
agendaposter = any([x.agendaposter for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]),
|
agendaposter = any([x.agendaposter for x in g.db.query(User).options(lazyload('*')).filter(User.id.in_(tuple(session.get("history", [])))).all() if x]),
|
||||||
club_banned=any([x.club_banned for x in g.db.query(User).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])
|
club_banned=any([x.club_banned for x in g.db.query(User).options(lazyload('*')).filter(User.id.in_(tuple(session.get("history", [])))).all() if x])
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(new_user)
|
g.db.add(new_user)
|
||||||
|
@ -391,7 +391,7 @@ def post_forgot():
|
||||||
|
|
||||||
email=email.replace("_","\_")
|
email=email.replace("_","\_")
|
||||||
|
|
||||||
user = g.db.query(User).filter(
|
user = g.db.query(User).options(lazyload('*')).filter(
|
||||||
User.username.ilike(username),
|
User.username.ilike(username),
|
||||||
User.email.ilike(email)).first()
|
User.email.ilike(email)).first()
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ def post_forgot():
|
||||||
email=email.split('+')[0]
|
email=email.split('+')[0]
|
||||||
email=email.replace('.','')
|
email=email.replace('.','')
|
||||||
email=f"{email}@gmail.com"
|
email=f"{email}@gmail.com"
|
||||||
user = g.db.query(User).filter(
|
user = g.db.query(User).options(lazyload('*')).filter(
|
||||||
User.username.ilike(username),
|
User.username.ilike(username),
|
||||||
User.email.ilike(email)).first()
|
User.email.ilike(email)).first()
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ def get_reset():
|
||||||
title="Password reset link expired",
|
title="Password reset link expired",
|
||||||
error="That password reset link has expired.")
|
error="That password reset link has expired.")
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
|
|
||||||
if not validate_hash(f"{user_id}+{timestamp}+forgot+{user.login_nonce}", token):
|
if not validate_hash(f"{user_id}+{timestamp}+forgot+{user.login_nonce}", token):
|
||||||
abort(400)
|
abort(400)
|
||||||
|
@ -472,7 +472,7 @@ def post_reset(v):
|
||||||
title="Password reset expired",
|
title="Password reset expired",
|
||||||
error="That password reset form has expired.")
|
error="That password reset form has expired.")
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(id=user_id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
|
||||||
|
|
||||||
if not validate_hash(f"{user_id}+{timestamp}+reset+{user.login_nonce}", token):
|
if not validate_hash(f"{user_id}+{timestamp}+reset+{user.login_nonce}", token):
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
|
@ -10,7 +10,7 @@ from files.__main__ import app
|
||||||
@auth_required
|
@auth_required
|
||||||
def authorize_prompt(v):
|
def authorize_prompt(v):
|
||||||
client_id = request.args.get("client_id")
|
client_id = request.args.get("client_id")
|
||||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
|
application = g.db.query(OauthApp).options(lazyload('*')).filter_by(client_id=client_id).first()
|
||||||
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
||||||
return render_template("oauth.html", v=v, application=application)
|
return render_template("oauth.html", v=v, application=application)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ def authorize_prompt(v):
|
||||||
def authorize(v):
|
def authorize(v):
|
||||||
|
|
||||||
client_id = request.form.get("client_id")
|
client_id = request.form.get("client_id")
|
||||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
|
application = g.db.query(OauthApp).options(lazyload('*')).filter_by(client_id=client_id).first()
|
||||||
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
||||||
access_token = secrets.token_urlsafe(128)[:128]
|
access_token = secrets.token_urlsafe(128)[:128]
|
||||||
new_auth = ClientAuth(
|
new_auth = ClientAuth(
|
||||||
|
@ -63,9 +63,9 @@ def request_api_keys(v):
|
||||||
def delete_oauth_app(v, aid):
|
def delete_oauth_app(v, aid):
|
||||||
|
|
||||||
aid = int(aid)
|
aid = int(aid)
|
||||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||||
|
|
||||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all():
|
for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all():
|
||||||
g.db.delete(auth)
|
g.db.delete(auth)
|
||||||
|
|
||||||
g.db.delete(app)
|
g.db.delete(app)
|
||||||
|
@ -81,7 +81,7 @@ def delete_oauth_app(v, aid):
|
||||||
def edit_oauth_app(v, aid):
|
def edit_oauth_app(v, aid):
|
||||||
|
|
||||||
aid = int(aid)
|
aid = int(aid)
|
||||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||||
|
|
||||||
app.redirect_uri = request.form.get('redirect_uri')
|
app.redirect_uri = request.form.get('redirect_uri')
|
||||||
app.app_name = request.form.get('name')
|
app.app_name = request.form.get('name')
|
||||||
|
@ -99,7 +99,7 @@ def edit_oauth_app(v, aid):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def admin_app_approve(v, aid):
|
def admin_app_approve(v, aid):
|
||||||
|
|
||||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||||
user = app.author
|
user = app.author
|
||||||
|
|
||||||
app.client_id = secrets.token_urlsafe(64)[:64]
|
app.client_id = secrets.token_urlsafe(64)[:64]
|
||||||
|
@ -126,16 +126,15 @@ def admin_app_approve(v, aid):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def admin_app_revoke(v, aid):
|
def admin_app_revoke(v, aid):
|
||||||
|
|
||||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||||
if app.id:
|
if app.id:
|
||||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||||
|
|
||||||
g.db.flush()
|
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been revoked.")
|
send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been revoked.")
|
||||||
|
|
||||||
g.db.delete(app)
|
g.db.delete(app)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return {"message": f"App revoked"}
|
return {"message": f"App revoked"}
|
||||||
|
|
||||||
|
@ -145,11 +144,10 @@ def admin_app_revoke(v, aid):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def admin_app_reject(v, aid):
|
def admin_app_reject(v, aid):
|
||||||
|
|
||||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
app = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||||
|
|
||||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
for auth in g.db.query(ClientAuth).options(lazyload('*')).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||||
|
|
||||||
g.db.flush()
|
|
||||||
send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been rejected.")
|
send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been rejected.")
|
||||||
|
|
||||||
g.db.delete(app)
|
g.db.delete(app)
|
||||||
|
@ -229,7 +227,7 @@ def reroll_oauth_tokens(aid, v):
|
||||||
|
|
||||||
aid = aid
|
aid = aid
|
||||||
|
|
||||||
a = g.db.query(OauthApp).filter_by(id=aid).first()
|
a = g.db.query(OauthApp).options(lazyload('*')).filter_by(id=aid).first()
|
||||||
|
|
||||||
if a.author_id != v.id: abort(403)
|
if a.author_id != v.id: abort(403)
|
||||||
|
|
||||||
|
|
|
@ -103,15 +103,15 @@ def post_id(pid, anything=None, v=None):
|
||||||
if post.club and not (v and v.paid_dues): abort(403)
|
if post.club and not (v and v.paid_dues): abort(403)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
blocking = v.blocking.subquery()
|
blocking = v.blocking.subquery()
|
||||||
|
|
||||||
blocked = v.blocked.subquery()
|
blocked = v.blocked.subquery()
|
||||||
|
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
|
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
|
||||||
shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery()
|
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
|
||||||
comments = g.db.query(Comment).filter(Comment.author_id.notin_(shadowbanned))
|
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id.notin_(shadowbanned))
|
||||||
|
|
||||||
comments = g.db.query(
|
comments = g.db.query(
|
||||||
Comment,
|
Comment,
|
||||||
|
@ -121,7 +121,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
)
|
)
|
||||||
|
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
|
if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
|
||||||
shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery()
|
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
|
||||||
comments = comments.filter(Comment.author_id.notin_(shadowbanned))
|
comments = comments.filter(Comment.author_id.notin_(shadowbanned))
|
||||||
|
|
||||||
if v.admin_level >=4:
|
if v.admin_level >=4:
|
||||||
|
@ -170,9 +170,8 @@ def post_id(pid, anything=None, v=None):
|
||||||
post.preloaded_comments = output
|
post.preloaded_comments = output
|
||||||
|
|
||||||
else:
|
else:
|
||||||
shadowbanned = g.db.query(User.id).filter(User.shadowbanned == True).subquery()
|
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned == True).all()]
|
||||||
|
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned))
|
||||||
comments = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.author_id.notin_(shadowbanned))
|
|
||||||
|
|
||||||
if sort == "top":
|
if sort == "top":
|
||||||
comments = sorted(comments.all(), key=lambda x: x.score, reverse=True)
|
comments = sorted(comments.all(), key=lambda x: x.score, reverse=True)
|
||||||
|
@ -202,8 +201,8 @@ def post_id(pid, anything=None, v=None):
|
||||||
# g.db.add(vote)
|
# g.db.add(vote)
|
||||||
# try: g.db.flush()
|
# try: g.db.flush()
|
||||||
# except: g.db.rollback()
|
# except: g.db.rollback()
|
||||||
# comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
|
# comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count()
|
||||||
# comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count()
|
# comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count()
|
||||||
# g.db.add(comment)
|
# g.db.add(comment)
|
||||||
|
|
||||||
post.preloaded_comments = comments
|
post.preloaded_comments = comments
|
||||||
|
@ -220,14 +219,15 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
for key in keys: session.pop(key)
|
for key in keys: session.pop(key)
|
||||||
|
|
||||||
#post.views += 1
|
post.views += 1
|
||||||
#g.db.add(post)
|
g.db.add(post)
|
||||||
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
|
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
|
||||||
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
|
if post.over_18 and not (v and v.over_18) and not session.get('over_18', 0) >= int(time.time()):
|
||||||
if request.headers.get("Authorization"): return {"error":"Must be 18+ to view"}, 451
|
if request.headers.get("Authorization"): return {"error":"Must be 18+ to view"}, 451
|
||||||
else: return render_template("errors/nsfw.html", v=v)
|
else: return render_template("errors/nsfw.html", v=v)
|
||||||
|
|
||||||
post.tree_comments()
|
post.tree_comments()
|
||||||
|
g.db.commit()
|
||||||
if request.headers.get("Authorization"): return post.json
|
if request.headers.get("Authorization"): return post.json
|
||||||
else:
|
else:
|
||||||
if not v or v.highlightcomments: return post.rendered_page(v=v, last_view_utc=last_view_utc, sort=sort)
|
if not v or v.highlightcomments: return post.rendered_page(v=v, last_view_utc=last_view_utc, sort=sort)
|
||||||
|
@ -285,7 +285,7 @@ def edit_post(pid, v):
|
||||||
fragment='')
|
fragment='')
|
||||||
check_url = urlunparse(check_url)
|
check_url = urlunparse(check_url)
|
||||||
|
|
||||||
badlink = g.db.query(BadLink).filter(
|
badlink = g.db.query(BadLink).options(lazyload('*')).filter(
|
||||||
literal(check_url).contains(
|
literal(check_url).contains(
|
||||||
BadLink.link)).first()
|
BadLink.link)).first()
|
||||||
if badlink:
|
if badlink:
|
||||||
|
@ -379,7 +379,7 @@ def edit_post(pid, v):
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
soup = BeautifulSoup(body_html, features="html.parser")
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
||||||
username = mention["href"].split("@")[1]
|
username = mention["href"].split("@")[1]
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first()
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user)
|
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user)
|
||||||
|
|
||||||
for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{p.permalink}")
|
for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{p.permalink}")
|
||||||
|
@ -448,7 +448,7 @@ def filter_title(title):
|
||||||
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
IMGUR_KEY = environ.get("IMGUR_KEY", "").strip()
|
||||||
|
|
||||||
|
|
||||||
def check_processing_thread(v, post, link, db):
|
def check_processing_thread(v, post, link):
|
||||||
|
|
||||||
image_id = link.split('/')[-1].rstrip('.mp4')
|
image_id = link.split('/')[-1].rstrip('.mp4')
|
||||||
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
headers = {"Authorization": f"Client-ID {IMGUR_KEY}"}
|
||||||
|
@ -463,16 +463,15 @@ def check_processing_thread(v, post, link, db):
|
||||||
status = req.json()['data']['processing']['status']
|
status = req.json()['data']['processing']['status']
|
||||||
if status == 'completed':
|
if status == 'completed':
|
||||||
post.processing = False
|
post.processing = False
|
||||||
db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
send_notification(
|
send_notification(
|
||||||
NOTIFICATIONS_ACCOUNT,
|
NOTIFICATIONS_ACCOUNT,
|
||||||
v,
|
v,
|
||||||
f"Your video has finished processing and your [post](/post/{post.id}) is now live.",
|
f"Your video has finished processing and your [post](/post/{post.id}) is now live."
|
||||||
db=db
|
|
||||||
)
|
)
|
||||||
|
|
||||||
db.commit()
|
g.db.commit()
|
||||||
break
|
break
|
||||||
# just in case
|
# just in case
|
||||||
elif status == 'failed':
|
elif status == 'failed':
|
||||||
|
@ -622,7 +621,7 @@ def submit_post(v):
|
||||||
url = url.replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg")
|
url = url.replace(".png", "_d.png").replace(".jpg", "_d.jpg").replace(".jpeg", "_d.jpeg")
|
||||||
if "_d." in url: url += "?maxwidth=9999"
|
if "_d." in url: url += "?maxwidth=9999"
|
||||||
|
|
||||||
repost = g.db.query(Submission).join(Submission.submission_aux).filter(
|
repost = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter(
|
||||||
SubmissionAux.url.ilike(url),
|
SubmissionAux.url.ilike(url),
|
||||||
Submission.deleted_utc == 0,
|
Submission.deleted_utc == 0,
|
||||||
Submission.is_banned == False
|
Submission.is_banned == False
|
||||||
|
@ -665,7 +664,7 @@ def submit_post(v):
|
||||||
|
|
||||||
body = request.form.get("body", "")
|
body = request.form.get("body", "")
|
||||||
# check for duplicate
|
# check for duplicate
|
||||||
dup = g.db.query(Submission).join(Submission.submission_aux).filter(
|
dup = g.db.query(Submission).join(Submission.submission_aux).options(lazyload('*')).filter(
|
||||||
|
|
||||||
Submission.author_id == v.id,
|
Submission.author_id == v.id,
|
||||||
Submission.deleted_utc == 0,
|
Submission.deleted_utc == 0,
|
||||||
|
@ -843,7 +842,7 @@ def submit_post(v):
|
||||||
fragment='')
|
fragment='')
|
||||||
check_url = urlunparse(check_url)
|
check_url = urlunparse(check_url)
|
||||||
|
|
||||||
badlink = g.db.query(BadLink).filter(
|
badlink = g.db.query(BadLink).options(lazyload('*')).filter(
|
||||||
literal(check_url).contains(
|
literal(check_url).contains(
|
||||||
BadLink.link)).first()
|
BadLink.link)).first()
|
||||||
if badlink:
|
if badlink:
|
||||||
|
@ -933,7 +932,7 @@ def submit_post(v):
|
||||||
post_url += 'mp4'
|
post_url += 'mp4'
|
||||||
new_post.url = post_url
|
new_post.url = post_url
|
||||||
new_post.processing = True
|
new_post.processing = True
|
||||||
gevent.spawn(check_processing_thread, v.id, new_post, post_url, g.db)
|
gevent.spawn(check_processing_thread, v.id, new_post, post_url)
|
||||||
except UploadException as e:
|
except UploadException as e:
|
||||||
if request.headers.get("Authorization"):
|
if request.headers.get("Authorization"):
|
||||||
return {
|
return {
|
||||||
|
@ -966,7 +965,7 @@ def submit_post(v):
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
soup = BeautifulSoup(body_html, features="html.parser")
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
||||||
username = mention["href"].split("@")[1]
|
username = mention["href"].split("@")[1]
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(username=username).first()
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user)
|
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user)
|
||||||
|
|
||||||
for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}")
|
for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}")
|
||||||
|
@ -1150,7 +1149,7 @@ def undelete_post_pid(pid, v):
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def toggle_comment_nsfw(cid, v):
|
def toggle_comment_nsfw(cid, v):
|
||||||
|
|
||||||
comment = g.db.query(Comment).filter_by(id=cid).first()
|
comment = g.db.query(Comment).options(lazyload('*')).filter_by(id=cid).first()
|
||||||
if not comment.author_id == v.id and not v.admin_level >= 3: abort(403)
|
if not comment.author_id == v.id and not v.admin_level >= 3: abort(403)
|
||||||
comment.over_18 = not comment.over_18
|
comment.over_18 = not comment.over_18
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
|
@ -1209,10 +1208,10 @@ def unsave_post(pid, v):
|
||||||
|
|
||||||
post=get_post(pid)
|
post=get_post(pid)
|
||||||
|
|
||||||
save=g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=post.id, type=1).first()
|
save=g.db.query(SaveRelationship).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id, type=1).first()
|
||||||
|
|
||||||
if save: g.db.delete(save)
|
if save:
|
||||||
|
g.db.delete(save)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return {"message": "Post unsaved!"}
|
return {"message": "Post unsaved!"}
|
||||||
|
|
|
@ -12,7 +12,7 @@ def api_flag_post(pid, v):
|
||||||
post = get_post(pid)
|
post = get_post(pid)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
existing = g.db.query(Flag).filter_by(user_id=v.id, post_id=post.id).first()
|
existing = g.db.query(Flag).options(lazyload('*')).filter_by(user_id=v.id, post_id=post.id).first()
|
||||||
|
|
||||||
if existing: return "", 409
|
if existing: return "", 409
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ def api_flag_comment(cid, v):
|
||||||
comment = get_comment(cid)
|
comment = get_comment(cid)
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
existing = g.db.query(CommentFlag).filter_by(
|
existing = g.db.query(CommentFlag).options(lazyload('*')).filter_by(
|
||||||
user_id=v.id, comment_id=comment.id).first()
|
user_id=v.id, comment_id=comment.id).first()
|
||||||
|
|
||||||
if existing: return "", 409
|
if existing: return "", 409
|
||||||
|
@ -75,9 +75,9 @@ def remove_report(report_fn, v):
|
||||||
return {"error": "go outside"}, 403
|
return {"error": "go outside"}, 403
|
||||||
|
|
||||||
if report_fn.startswith('c'):
|
if report_fn.startswith('c'):
|
||||||
report = g.db.query(CommentFlag).filter_by(id=int(report_fn.lstrip('c'))).first()
|
report = g.db.query(CommentFlag).options(lazyload('*')).filter_by(id=int(report_fn.lstrip('c'))).first()
|
||||||
elif report_fn.startswith('p'):
|
elif report_fn.startswith('p'):
|
||||||
report = g.db.query(Flag).filter_by(id=int(report_fn.lstrip('p'))).first()
|
report = g.db.query(Flag).options(lazyload('*')).filter_by(id=int(report_fn.lstrip('p'))).first()
|
||||||
else:
|
else:
|
||||||
return {"error": "Invalid report ID"}, 400
|
return {"error": "Invalid report ID"}, 400
|
||||||
|
|
||||||
|
|
|
@ -88,12 +88,12 @@ def searchlisting(criteria, v=None, page=1, t="None", sort="top", b=None):
|
||||||
if v and v.admin_level >= 4:
|
if v and v.admin_level >= 4:
|
||||||
pass
|
pass
|
||||||
elif v:
|
elif v:
|
||||||
blocking = g.db.query(
|
blocking = [x[0] for x in g.db.query(
|
||||||
UserBlock.target_id).filter_by(
|
UserBlock.target_id).filter_by(
|
||||||
user_id=v.id).subquery()
|
user_id=v.id).all()]
|
||||||
blocked = g.db.query(
|
blocked = [x[0] for x in g.db.query(
|
||||||
UserBlock.user_id).filter_by(
|
UserBlock.user_id).filter_by(
|
||||||
target_id=v.id).subquery()
|
target_id=v.id).all()]
|
||||||
|
|
||||||
posts = posts.filter(
|
posts = posts.filter(
|
||||||
Submission.author_id.notin_(blocking),
|
Submission.author_id.notin_(blocking),
|
||||||
|
@ -150,7 +150,7 @@ def searchlisting(criteria, v=None, page=1, t="None", sort="top", b=None):
|
||||||
|
|
||||||
def searchcommentlisting(criteria, v=None, page=1, t="None", sort="top"):
|
def searchcommentlisting(criteria, v=None, page=1, t="None", sort="top"):
|
||||||
|
|
||||||
comments = g.db.query(Comment).options(lazyload('*')).filter(Comment.parent_submission != None).join(Comment.comment_aux)
|
comments = g.db.query(Comment).options(lazyload('*')).options(lazyload('*')).filter(Comment.parent_submission != None).join(Comment.comment_aux)
|
||||||
|
|
||||||
if 'q' in criteria:
|
if 'q' in criteria:
|
||||||
words=criteria['q'].split()
|
words=criteria['q'].split()
|
||||||
|
@ -278,7 +278,7 @@ def searchusers(v):
|
||||||
term=term.replace('\\','')
|
term=term.replace('\\','')
|
||||||
term=term.replace('_','\_')
|
term=term.replace('_','\_')
|
||||||
|
|
||||||
users=g.db.query(User).filter(User.username.ilike(f'%{term}%'))
|
users=g.db.query(User).options(lazyload('*')).filter(User.username.ilike(f'%{term}%'))
|
||||||
|
|
||||||
users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc())
|
users=users.order_by(User.username.ilike(term).desc(), User.stored_subscriber_count.desc())
|
||||||
|
|
||||||
|
|
|
@ -417,7 +417,7 @@ def settings_security_post(v):
|
||||||
return redirect("/settings/security?error=That email is already yours!")
|
return redirect("/settings/security?error=That email is already yours!")
|
||||||
|
|
||||||
# check to see if email is in use
|
# check to see if email is in use
|
||||||
existing = g.db.query(User).filter(User.id != v.id,
|
existing = g.db.query(User).options(lazyload('*')).filter(User.id != v.id,
|
||||||
func.lower(User.email) == new_email.lower()).first()
|
func.lower(User.email) == new_email.lower()).first()
|
||||||
if existing:
|
if existing:
|
||||||
return redirect("/settings/security?error=" +
|
return redirect("/settings/security?error=" +
|
||||||
|
@ -652,7 +652,7 @@ def settings_block_user(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
existing = g.db.query(Notification).filter_by(blocksender=v.id, user_id=user.id).first()
|
existing = g.db.query(Notification).options(lazyload('*')).filter_by(blocksender=v.id, user_id=user.id).first()
|
||||||
if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!")
|
if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!")
|
||||||
|
|
||||||
if v.admin_level == 1: return {"message": f"@{user.username} banned!"}
|
if v.admin_level == 1: return {"message": f"@{user.username} banned!"}
|
||||||
|
@ -679,7 +679,7 @@ def settings_unblock_user(v):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
existing = g.db.query(Notification).filter_by(unblocksender=v.id, user_id=user.id).first()
|
existing = g.db.query(Notification).options(lazyload('*')).filter_by(unblocksender=v.id, user_id=user.id).first()
|
||||||
if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!")
|
if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!")
|
||||||
|
|
||||||
if v.admin_level == 1: return {"message": f"@{user.username} unbanned!"}
|
if v.admin_level == 1: return {"message": f"@{user.username} unbanned!"}
|
||||||
|
@ -759,7 +759,7 @@ def settings_name_change(v):
|
||||||
v=v,
|
v=v,
|
||||||
error=f"Username `{new_name}` is already in use.")
|
error=f"Username `{new_name}` is already in use.")
|
||||||
|
|
||||||
v=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=v.id).first()
|
v=g.db.query(User).with_for_update().options(lazyload('*')).options(lazyload('*')).filter_by(id=v.id).first()
|
||||||
|
|
||||||
v.username=new_name
|
v.username=new_name
|
||||||
v.name_changed_utc=int(time.time())
|
v.name_changed_utc=int(time.time())
|
||||||
|
@ -778,7 +778,7 @@ def settings_name_change(v):
|
||||||
def settings_song_change(v):
|
def settings_song_change(v):
|
||||||
song=request.form.get("song").strip()
|
song=request.form.get("song").strip()
|
||||||
|
|
||||||
if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
if song == "" and v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).options(lazyload('*')).filter_by(song=v.song).count() == 1:
|
||||||
os.remove(f"/songs/{v.song}.mp3")
|
os.remove(f"/songs/{v.song}.mp3")
|
||||||
v.song=None
|
v.song=None
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
@ -821,7 +821,7 @@ def settings_song_change(v):
|
||||||
error=f"Duration of the video must not exceed 10 minutes.")
|
error=f"Duration of the video must not exceed 10 minutes.")
|
||||||
|
|
||||||
|
|
||||||
if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
if v.song and path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).options(lazyload('*')).filter_by(song=v.song).count() == 1:
|
||||||
os.remove(f"/songs/{v.song}.mp3")
|
os.remove(f"/songs/{v.song}.mp3")
|
||||||
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
|
|
|
@ -33,28 +33,28 @@ def participation_stats(v):
|
||||||
day = now - 86400
|
day = now - 86400
|
||||||
|
|
||||||
data = {"valid_users": g.db.query(User).count(),
|
data = {"valid_users": g.db.query(User).count(),
|
||||||
"private_users": g.db.query(User).filter_by(is_private=True).count(),
|
"private_users": g.db.query(User).options(lazyload('*')).filter_by(is_private=True).count(),
|
||||||
"banned_users": g.db.query(User).filter(User.is_banned > 0).count(),
|
"banned_users": g.db.query(User).options(lazyload('*')).filter(User.is_banned > 0).count(),
|
||||||
"verified_email_users": g.db.query(User).filter_by(is_activated=True).count(),
|
"verified_email_users": g.db.query(User).options(lazyload('*')).filter_by(is_activated=True).count(),
|
||||||
"total_coins": g.db.query(func.sum(User.coins)).scalar(),
|
"total_coins": g.db.query(func.sum(User.coins)).scalar(),
|
||||||
"signups_last_24h": g.db.query(User).filter(User.created_utc > day).count(),
|
"signups_last_24h": g.db.query(User).options(lazyload('*')).filter(User.created_utc > day).count(),
|
||||||
"total_posts": g.db.query(Submission).count(),
|
"total_posts": g.db.query(Submission).count(),
|
||||||
"posting_users": g.db.query(Submission.author_id).distinct().count(),
|
"posting_users": g.db.query(Submission.author_id).distinct().count(),
|
||||||
"listed_posts": g.db.query(Submission).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
|
"listed_posts": g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
|
||||||
"removed_posts": g.db.query(Submission).filter_by(is_banned=True).count(),
|
"removed_posts": g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=True).count(),
|
||||||
"deleted_posts": g.db.query(Submission).filter(Submission.deleted_utc > 0).count(),
|
"deleted_posts": g.db.query(Submission).options(lazyload('*')).filter(Submission.deleted_utc > 0).count(),
|
||||||
"posts_last_24h": g.db.query(Submission).filter(Submission.created_utc > day).count(),
|
"posts_last_24h": g.db.query(Submission).options(lazyload('*')).filter(Submission.created_utc > day).count(),
|
||||||
"total_comments": g.db.query(Comment).count(),
|
"total_comments": g.db.query(Comment).count(),
|
||||||
"commenting_users": g.db.query(Comment.author_id).distinct().count(),
|
"commenting_users": g.db.query(Comment.author_id).distinct().count(),
|
||||||
"removed_comments": g.db.query(Comment).filter_by(is_banned=True).count(),
|
"removed_comments": g.db.query(Comment).options(lazyload('*')).filter_by(is_banned=True).count(),
|
||||||
"deleted_comments": g.db.query(Comment).filter(Comment.deleted_utc>0).count(),
|
"deleted_comments": g.db.query(Comment).options(lazyload('*')).filter(Comment.deleted_utc>0).count(),
|
||||||
"comments_last_24h": g.db.query(Comment).filter(Comment.created_utc > day).count(),
|
"comments_last_24h": g.db.query(Comment).options(lazyload('*')).filter(Comment.created_utc > day).count(),
|
||||||
"post_votes": g.db.query(Vote).count(),
|
"post_votes": g.db.query(Vote).count(),
|
||||||
"post_voting_users": g.db.query(Vote.user_id).distinct().count(),
|
"post_voting_users": g.db.query(Vote.user_id).distinct().count(),
|
||||||
"comment_votes": g.db.query(CommentVote).count(),
|
"comment_votes": g.db.query(CommentVote).count(),
|
||||||
"comment_voting_users": g.db.query(CommentVote.user_id).distinct().count(),
|
"comment_voting_users": g.db.query(CommentVote.user_id).distinct().count(),
|
||||||
"total_awards": g.db.query(AwardRelationship).count(),
|
"total_awards": g.db.query(AwardRelationship).count(),
|
||||||
"awards_given": g.db.query(AwardRelationship).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count()
|
"awards_given": g.db.query(AwardRelationship).options(lazyload('*')).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ def patrons(v):
|
||||||
@app.get("/badmins")
|
@app.get("/badmins")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def admins(v):
|
def admins(v):
|
||||||
admins = g.db.query(User).filter_by(admin_level=6).order_by(User.coins.desc()).all()
|
admins = g.db.query(User).options(lazyload('*')).filter_by(admin_level=6).order_by(User.coins.desc()).all()
|
||||||
return render_template("admins.html", v=v, admins=admins)
|
return render_template("admins.html", v=v, admins=admins)
|
||||||
|
|
||||||
@app.get("/log")
|
@app.get("/log")
|
||||||
|
@ -100,7 +100,7 @@ def log(v):
|
||||||
page=int(request.args.get("page",1))
|
page=int(request.args.get("page",1))
|
||||||
|
|
||||||
if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all()
|
||||||
else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all()
|
else: actions=g.db.query(ModAction).options(lazyload('*')).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all()
|
||||||
|
|
||||||
next_exists=len(actions)==26
|
next_exists=len(actions)==26
|
||||||
actions=actions[:25]
|
actions=actions[:25]
|
||||||
|
@ -116,7 +116,7 @@ def log_item(id, v):
|
||||||
try: id = int(id, 36)
|
try: id = int(id, 36)
|
||||||
except: abort(404)
|
except: abort(404)
|
||||||
|
|
||||||
action=g.db.query(ModAction).filter_by(id=id).first()
|
action=g.db.query(ModAction).options(lazyload('*')).filter_by(id=id).first()
|
||||||
|
|
||||||
if not action:
|
if not action:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
@ -228,7 +228,7 @@ def blocks(v):
|
||||||
def banned(v):
|
def banned(v):
|
||||||
|
|
||||||
|
|
||||||
users = [x for x in g.db.query(User).filter(User.is_banned > 0, User.unban_utc == 0).all()]
|
users = [x for x in g.db.query(User).options(lazyload('*')).filter(User.is_banned > 0, User.unban_utc == 0).all()]
|
||||||
return render_template("banned.html", v=v, users=users)
|
return render_template("banned.html", v=v, users=users)
|
||||||
|
|
||||||
@app.get("/formatting")
|
@app.get("/formatting")
|
||||||
|
|
|
@ -77,16 +77,16 @@ def steal(v):
|
||||||
@app.get("/rentoids")
|
@app.get("/rentoids")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def rentoids(v):
|
def rentoids(v):
|
||||||
users = g.db.query(User).filter(User.rent_utc > 0).all()
|
users = g.db.query(User).options(lazyload('*')).filter(User.rent_utc > 0).all()
|
||||||
return render_template("rentoids.html", v=v, users=users)
|
return render_template("rentoids.html", v=v, users=users)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/thiefs")
|
@app.get("/thiefs")
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def thiefs(v):
|
def thiefs(v):
|
||||||
successful = g.db.query(User).filter(User.steal_utc > 0).all()
|
successful = g.db.query(User).options(lazyload('*')).filter(User.steal_utc > 0).all()
|
||||||
failed = g.db.query(User).filter(User.fail_utc > 0).all()
|
failed = g.db.query(User).options(lazyload('*')).filter(User.fail_utc > 0).all()
|
||||||
failed2 = g.db.query(User).filter(User.fail2_utc > 0).all()
|
failed2 = g.db.query(User).options(lazyload('*')).filter(User.fail2_utc > 0).all()
|
||||||
return render_template("thiefs.html", v=v, successful=successful, failed=failed, failed2=failed2)
|
return render_template("thiefs.html", v=v, successful=successful, failed=failed, failed2=failed2)
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,8 +133,7 @@ def transfer_coins(v, username):
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!"
|
transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!"
|
||||||
send_notification(v.id, receiver, transfer_message)
|
send_notification(NOTIFICATIONS_ACCOUNT, receiver, transfer_message)
|
||||||
return {"message": f"{amount} {app.config['COINS_NAME']} transferred!"}, 200
|
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
@ -177,7 +176,7 @@ def get_profilecss(username):
|
||||||
def songs(id):
|
def songs(id):
|
||||||
try: id = int(id)
|
try: id = int(id)
|
||||||
except: return "", 400
|
except: return "", 400
|
||||||
user = g.db.query(User).filter_by(id=id).first()
|
user = g.db.query(User).options(lazyload('*')).filter_by(id=id).first()
|
||||||
return redirect(f"/song/{user.song}.mp3")
|
return redirect(f"/song/{user.song}.mp3")
|
||||||
|
|
||||||
@app.get("/song/<song>")
|
@app.get("/song/<song>")
|
||||||
|
@ -198,7 +197,7 @@ def subscribe(v, post_id):
|
||||||
@app.post("/unsubscribe/<post_id>")
|
@app.post("/unsubscribe/<post_id>")
|
||||||
@auth_required
|
@auth_required
|
||||||
def unsubscribe(v, post_id):
|
def unsubscribe(v, post_id):
|
||||||
sub=g.db.query(Subscription).filter_by(user_id=v.id, submission_id=post_id).first()
|
sub=g.db.query(Subscription).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post_id).first()
|
||||||
g.db.delete(sub)
|
g.db.delete(sub)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Post unsubscribed!"}
|
return {"message": "Post unsubscribed!"}
|
||||||
|
@ -216,7 +215,7 @@ def message2(v, username):
|
||||||
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
|
|
||||||
# check existing
|
# check existing
|
||||||
existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.sentto == user.id,
|
Comment.sentto == user.id,
|
||||||
CommentAux.body == message,
|
CommentAux.body == message,
|
||||||
).options(contains_eager(Comment.comment_aux)).first()
|
).options(contains_eager(Comment.comment_aux)).first()
|
||||||
|
@ -256,7 +255,7 @@ def messagereply(v):
|
||||||
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
message = message.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
|
||||||
|
|
||||||
# check existing
|
# check existing
|
||||||
existing = g.db.query(Comment).join(CommentAux).filter(Comment.author_id == v.id,
|
existing = g.db.query(Comment).join(CommentAux).options(lazyload('*')).filter(Comment.author_id == v.id,
|
||||||
Comment.sentto == user.id,
|
Comment.sentto == user.id,
|
||||||
CommentAux.body == message,
|
CommentAux.body == message,
|
||||||
).options(contains_eager(Comment.comment_aux)).first()
|
).options(contains_eager(Comment.comment_aux)).first()
|
||||||
|
@ -384,7 +383,7 @@ def u_username(username, v=None):
|
||||||
|
|
||||||
# viewers
|
# viewers
|
||||||
if v and u.id != v.id:
|
if v and u.id != v.id:
|
||||||
view = g.db.query(ViewerRelationship).filter(
|
view = g.db.query(ViewerRelationship).options(lazyload('*')).filter(
|
||||||
and_(
|
and_(
|
||||||
ViewerRelationship.viewer_id == v.id,
|
ViewerRelationship.viewer_id == v.id,
|
||||||
ViewerRelationship.user_id == u.id
|
ViewerRelationship.user_id == u.id
|
||||||
|
@ -436,7 +435,7 @@ def u_username(username, v=None):
|
||||||
# If page 1, check for sticky
|
# If page 1, check for sticky
|
||||||
if page == 1:
|
if page == 1:
|
||||||
sticky = []
|
sticky = []
|
||||||
sticky = g.db.query(Submission).filter_by(is_pinned=True, author_id=u.id).all()
|
sticky = g.db.query(Submission).options(lazyload('*')).filter_by(is_pinned=True, author_id=u.id).all()
|
||||||
if sticky:
|
if sticky:
|
||||||
for p in sticky:
|
for p in sticky:
|
||||||
ids = [p.id] + ids
|
ids = [p.id] + ids
|
||||||
|
@ -597,15 +596,15 @@ def follow_user(username, v):
|
||||||
if target.id==v.id: return {"error": "You can't follow yourself!"}, 400
|
if target.id==v.id: return {"error": "You can't follow yourself!"}, 400
|
||||||
|
|
||||||
# check for existing follow
|
# check for existing follow
|
||||||
if g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first(): return {"message": "User followed!"}
|
if g.db.query(Follow).options(lazyload('*')).filter_by(user_id=v.id, target_id=target.id).first(): return {"message": "User followed!"}
|
||||||
|
|
||||||
new_follow = Follow(user_id=v.id, target_id=target.id)
|
new_follow = Follow(user_id=v.id, target_id=target.id)
|
||||||
g.db.add(new_follow)
|
g.db.add(new_follow)
|
||||||
|
|
||||||
target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count()
|
target.stored_subscriber_count = g.db.query(Follow).options(lazyload('*')).filter_by(target_id=target.id).count()
|
||||||
g.db.add(target)
|
g.db.add(target)
|
||||||
|
|
||||||
existing = g.db.query(Notification).filter_by(followsender=v.id, user_id=target.id).first()
|
existing = g.db.query(Notification).options(lazyload('*')).filter_by(followsender=v.id, user_id=target.id).first()
|
||||||
if not existing: send_follow_notif(v.id, target.id, f"@{v.username} has followed you!")
|
if not existing: send_follow_notif(v.id, target.id, f"@{v.username} has followed you!")
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -619,15 +618,15 @@ def unfollow_user(username, v):
|
||||||
target = get_user(username)
|
target = get_user(username)
|
||||||
|
|
||||||
# check for existing follow
|
# check for existing follow
|
||||||
follow = g.db.query(Follow).filter_by(user_id=v.id, target_id=target.id).first()
|
follow = g.db.query(Follow).options(lazyload('*')).filter_by(user_id=v.id, target_id=target.id).first()
|
||||||
|
|
||||||
if not follow: return {"message": "User unfollowed!"}
|
if not follow: return {"message": "User unfollowed!"}
|
||||||
|
|
||||||
g.db.delete(follow)
|
g.db.delete(follow)
|
||||||
target.stored_subscriber_count = g.db.query(Follow).filter_by(target_id=target.id).count()
|
target.stored_subscriber_count = g.db.query(Follow).options(lazyload('*')).filter_by(target_id=target.id).count()
|
||||||
g.db.add(target)
|
g.db.add(target)
|
||||||
|
|
||||||
existing = g.db.query(Notification).filter_by(unfollowsender=v.id, user_id=target.id).first()
|
existing = g.db.query(Notification).options(lazyload('*')).filter_by(unfollowsender=v.id, user_id=target.id).first()
|
||||||
if not existing: send_unfollow_notif(v.id, target.id, f"@{v.username} has unfollowed you!")
|
if not existing: send_unfollow_notif(v.id, target.id, f"@{v.username} has unfollowed you!")
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
|
@ -69,7 +69,7 @@ def api_vote_post(post_id, new, v):
|
||||||
post = get_post(post_id)
|
post = get_post(post_id)
|
||||||
|
|
||||||
# check for existing vote
|
# check for existing vote
|
||||||
existing = g.db.query(Vote).filter_by(user_id=v.id, submission_id=post.id).first()
|
existing = g.db.query(Vote).options(lazyload('*')).filter_by(user_id=v.id, submission_id=post.id).first()
|
||||||
|
|
||||||
if existing and existing.vote_type == new: return "", 204
|
if existing and existing.vote_type == new: return "", 204
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ def api_vote_post(post_id, new, v):
|
||||||
)
|
)
|
||||||
g.db.add(vote)
|
g.db.add(vote)
|
||||||
|
|
||||||
post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count()
|
post.upvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=1).count()
|
||||||
post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count()
|
post.downvotes = g.db.query(Vote).options(lazyload('*')).filter_by(submission_id=post.id, vote_type=-1).count()
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return "", 204
|
return "", 204
|
||||||
|
@ -121,7 +121,7 @@ def api_vote_comment(comment_id, new, v):
|
||||||
comment = get_comment(comment_id)
|
comment = get_comment(comment_id)
|
||||||
|
|
||||||
# check for existing vote
|
# check for existing vote
|
||||||
existing = g.db.query(CommentVote).filter_by(user_id=v.id, comment_id=comment.id).first()
|
existing = g.db.query(CommentVote).options(lazyload('*')).filter_by(user_id=v.id, comment_id=comment.id).first()
|
||||||
|
|
||||||
if existing and existing.vote_type == new: return "", 204
|
if existing and existing.vote_type == new: return "", 204
|
||||||
|
|
||||||
|
@ -149,8 +149,8 @@ def api_vote_comment(comment_id, new, v):
|
||||||
|
|
||||||
g.db.add(vote)
|
g.db.add(vote)
|
||||||
|
|
||||||
comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=1).count()
|
comment.upvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=1).count()
|
||||||
comment.downvotes = g.db.query(CommentVote).filter_by(comment_id=comment.id, vote_type=-1).count()
|
comment.downvotes = g.db.query(CommentVote).options(lazyload('*')).filter_by(comment_id=comment.id, vote_type=-1).count()
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return "", 204
|
return "", 204
|
|
@ -1,7 +0,0 @@
|
||||||
const vm = new Vue({
|
|
||||||
el: '#vm',
|
|
||||||
delimiters: ['[[', ']]'],
|
|
||||||
data: {
|
|
||||||
greeting: 'Hello, Vue!'
|
|
||||||
}
|
|
||||||
})
|
|
|
@ -1,5 +1,3 @@
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
|
|
||||||
|
|
||||||
<input type="hidden" id="awardTarget" value="" />
|
<input type="hidden" id="awardTarget" value="" />
|
||||||
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered" role="document">
|
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered" role="document">
|
||||||
|
@ -11,45 +9,33 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="awardModalBody" class="modal-body">
|
<div id="awardModalBody" class="modal-body">
|
||||||
<form v-if="loaded" id="sex" class="pt-3 pb-0">
|
<form class="pt-3 pb-0" action="/post/{{p.id}}/awards" method="post">
|
||||||
<div class="card-columns awards-wrapper">
|
<div class="card-columns awards-wrapper">
|
||||||
<div v-for="(award, index) in awards" :key="index">
|
{% for award in v.user_awards %}
|
||||||
<input type="radio" :id="index" :value="index" v-model="picked" :disabled="award.owned < 1">
|
<div>
|
||||||
<label class="card" :for="index" :class="{ disabled: award.owned < 1 }">
|
<label class="card" onclick="document.getElementById('desc-{{award.kind}}').classList.toggle('d-none');document.getElementById('giveaward').disabled=false">
|
||||||
<i :class="award.icon+' '+award.color"></i><br />
|
<i class="{{award.icon}} {{award.color}}"></i><br />
|
||||||
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px;">[[ award.title ]]</span>
|
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px;">{{award.title}}</span>
|
||||||
<span class="text-muted">[[ award.owned ]] owned</span>
|
<span class="text-muted">{{award.owned}} owned</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="picked !== null">
|
|
||||||
<div class="award-desc p-3">
|
|
||||||
<i style="font-size: 35px;" :class="pickedAward.icon+' '+pickedAward.color"></i>
|
|
||||||
<div style="margin-left: 15px;">
|
|
||||||
<strong>[[ pickedAward.title ]] Award</strong><br />
|
|
||||||
<span class="text-muted">[[ pickedAward.description ]]</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div id="desc-{{award.kind}}" class="d-none">
|
||||||
<label for="note" class="pt-4">Note (optional):</label>
|
<div class="award-desc p-3">
|
||||||
<textarea id="note" name="note" v-model="note" class="form-control" placeholder="Note to include in award notification"></textarea>
|
<i style="font-size: 35px;"></i>
|
||||||
|
<div style="margin-left: 15px;">
|
||||||
|
<strong>{{pickedAward.title}} Award</strong><br />
|
||||||
|
<span class="text-muted">{{pickedAward.description}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<label for="note" class="pt-4">Note (optional):</label>
|
||||||
|
<textarea id="note" name="note" class="form-control" placeholder="Note to include in award notification"></textarea>
|
||||||
|
</div>
|
||||||
|
<input name="{{award.kind}}" hidden>
|
||||||
|
<input id="giveaward" class="btn btn-primary" type="submit" value="Give Award" disabled>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div v-else-if="error" class="p-5 text-center">
|
|
||||||
<h4>Failed to fetch awards</h4>
|
|
||||||
<button class="btn btn-primary">Retry</button>
|
|
||||||
</div>
|
|
||||||
<div v-else class="p-5 text-center">
|
|
||||||
<h4>Loading...</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-link text-muted" data-dismiss="modal">Cancel</button>
|
|
||||||
<button v-if="pending" class="btn btn-warning" type="button" disabled>
|
|
||||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
|
||||||
Gifting...
|
|
||||||
</button>
|
|
||||||
<button v-else type="submit" class="btn btn-link" id="awardButton" @click="submit" :disabled="pickedAward === null">Give Award</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -91,62 +77,4 @@
|
||||||
background-color: rgba(221, 221, 221, 0.23);
|
background-color: rgba(221, 221, 221, 0.23);
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
|
||||||
new Vue({
|
|
||||||
el: "#awardModal",
|
|
||||||
delimiters: ['[[', ']]'],
|
|
||||||
data: {
|
|
||||||
loaded: false,
|
|
||||||
error: false,
|
|
||||||
pending: false,
|
|
||||||
awards: [],
|
|
||||||
picked: null,
|
|
||||||
note: ""
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
pickedAward: function() {
|
|
||||||
if (this.picked !== null) {
|
|
||||||
return this.awards[this.picked];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async submit() {
|
|
||||||
this.pending = true;
|
|
||||||
|
|
||||||
const target = document.getElementById("awardTarget").value;
|
|
||||||
|
|
||||||
const f = new FormData();
|
|
||||||
f.append("formkey", formkey());
|
|
||||||
f.append("kind", this.pickedAward.kind || "");
|
|
||||||
f.append("note", this.note)
|
|
||||||
|
|
||||||
let response = await fetch(target, {
|
|
||||||
method: "POST",
|
|
||||||
body: f
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
location.reload();
|
|
||||||
} else {
|
|
||||||
this.pending = false;
|
|
||||||
let s = await response.json();
|
|
||||||
alert(s.error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
fetch('/awards')
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(json => {
|
|
||||||
this.awards = json;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.loaded = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
|
@ -9,7 +9,6 @@
|
||||||
{% set ups=c.upvotes %}
|
{% set ups=c.upvotes %}
|
||||||
{% set downs=c.downvotes %}
|
{% set downs=c.downvotes %}
|
||||||
{% set score=ups-downs %}
|
{% set score=ups-downs %}
|
||||||
{% include "emoji_modal.html" %}
|
|
||||||
|
|
||||||
{% if v and v.shadowbanned %}
|
{% if v and v.shadowbanned %}
|
||||||
{% set replies=c.replies3 %}
|
{% set replies=c.replies3 %}
|
||||||
|
@ -271,8 +270,7 @@
|
||||||
<li id="save-{{c.id}}" class="{% if not c in v.saved_comment_idlist() %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a href="javascript:void(0)" onclick="post_toast3('/save_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}')"><i class="fas fa-save"></i>Save</a></li>
|
<li id="save-{{c.id}}" class="{% if not c in v.saved_comment_idlist() %}d-md-inline-block{% endif %} list-inline-item text-muted d-none"><a href="javascript:void(0)" onclick="post_toast3('/save_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}')"><i class="fas fa-save"></i>Save</a></li>
|
||||||
|
|
||||||
{% if v.id!=c.author_id %}
|
{% if v.id!=c.author_id %}
|
||||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" data-toggle="modal" data-target="#awardModal" onclick="awardModal('/comment/{{c.id}}/awards')"><i class="fas fa-gift"
|
<li class="list-inline-item text-muted"><a href="javascript:void(0)" data-toggle="modal" data-target="#awardModal" onclick="awardModal('/comment/{{c.id}}/awards')"><i class="fas fa-gift" aria-hidden="true"></i><span class="d-none d-md-inline-block">Give Award</span></a></li>
|
||||||
aria-hidden="true"></i><span class="d-none d-md-inline-block">Give Award</span></a></li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<li class="list-inline-item text-muted"><a href="javascript:void(0)" onclick="openReplyBox('{{c.id}}')"><i class="fas fa-reply" aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a></li>
|
<li class="list-inline-item text-muted"><a href="javascript:void(0)" onclick="openReplyBox('{{c.id}}')"><i class="fas fa-reply" aria-hidden="true"></i><span class="d-none d-md-inline-block">Reply</span></a></li>
|
||||||
|
@ -528,4 +526,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if v %}
|
||||||
|
{% include "gif_modal.html" %}
|
||||||
|
{% include "emoji_modal.html" %}
|
||||||
|
{% include "award_modal.html" %}
|
||||||
|
{% include "delete_comment_modal.html" %}
|
||||||
|
{% endif %}
|
||||||
|
{% include "expanded_image_modal.html" %}
|
||||||
|
{% include "flag_comment_modal.html" %}
|
||||||
</body>
|
</body>
|
|
@ -1322,7 +1322,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block mobilenavbar %}
|
{% block mobilenavbar %}
|
||||||
{% include "mobile_navigation_bar.html" %}
|
{% include "mobile_navigation_bar.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block actionsModal %}
|
{% block actionsModal %}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<style>
|
<style>
|
||||||
a.nav-link {
|
a.emojitab {
|
||||||
padding: 0.5rem 0.7rem !important;
|
padding: 0.5rem 0.7rem !important;
|
||||||
font-size: 13px !important;
|
font-size: 13px !important;
|
||||||
}
|
}
|
||||||
|
@ -22,28 +22,28 @@
|
||||||
<div>
|
<div>
|
||||||
<ul class="nav nav-pills py-2">
|
<ul class="nav nav-pills py-2">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active " data-toggle="tab" href="#emoji-tab-favorite">Favorite</a>
|
<a class="nav-link active emojitab" data-toggle="tab" href="#emoji-tab-favorite">Favorite</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-marsey">Marsey</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-marsey">Marsey</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-platy">Platy</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-platy">Platy</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-tay">Tay</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-tay">Tay</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-classic">Classic</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-classic">Classic</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-rage">Rage</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-rage">Rage</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-wojak">Wojak</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-wojak">Wojak</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " data-toggle="tab" href="#emoji-tab-flags">Flags</a>
|
<a class="nav-link emojitab" data-toggle="tab" href="#emoji-tab-flags">Flags</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
<body>
|
|
||||||
<div id="vm">
|
|
||||||
<p>{{greeting}}</p>
|
|
||||||
<p>[[ greeting ]]</p>
|
|
||||||
</div>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
||||||
<script src="{{url_for('static', filename='index.js')}}"></script>
|
|
||||||
</body>
|
|
|
@ -156,6 +156,9 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if request.path=='/settings/apps' %} active{% endif %}" href="/settings/apps">Apps</a>
|
<a class="nav-link{% if request.path=='/settings/apps' %} active{% endif %}" href="/settings/apps">Apps</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link{% if 'shop' in request.path %} active{% endif %}" href="/settings/shop">Shop</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -186,6 +189,9 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if request.path=='/settings/apps' %} active{% endif %} px-25 " href="/settings/apps"><i class="fas fa-code text-lg mr-0"></i></a>
|
<a class="nav-link{% if request.path=='/settings/apps' %} active{% endif %} px-25 " href="/settings/apps"><i class="fas fa-code text-lg mr-0"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link{% if 'shop' in request.path %} active{% endif %} px-25 " href="/settings/shop"><i class="fas fa-store text-lg mr-0"></i></a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "default.html" %}
|
{% extends "settings.html" %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
<title>Shop</title>
|
<title>Shop</title>
|
|
@ -669,7 +669,7 @@
|
||||||
{% if p.replies %}
|
{% if p.replies %}
|
||||||
<div class="comment-section">
|
<div class="comment-section">
|
||||||
{% with comments=p.replies %}
|
{% with comments=p.replies %}
|
||||||
{% include "comments.html" %}
|
{% include "comments.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
{% elif not p.replies and p.deleted_utc == 0 %}
|
{% elif not p.replies and p.deleted_utc == 0 %}
|
||||||
|
@ -692,25 +692,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if v and v.id==p.author_id %}
|
{% if v and v.id==p.author_id %}
|
||||||
{% include "delete_post_modal.html" %}
|
{% include "delete_post_modal.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% include "delete_comment_modal.html" %}
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block GIFtoast %}
|
|
||||||
<div class="toast" id="toast-error-gif" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; z-index: 1000" role="alert" aria-live="assertive" aria-atomic="true" data-animation="true" data-autohide="true" data-delay="5000">
|
|
||||||
<div class="toast-body bg-danger text-center text-white">
|
|
||||||
<i class="fas fa-exclamation-circle mr-2"></i>Unable to snag gifs :(
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block GIFpicker %}
|
|
||||||
{% if v %}
|
|
||||||
{% include "gif_modal.html" %}
|
|
||||||
{% include "emoji_modal.html" %}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
|
@ -496,4 +496,9 @@
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% include "delete_post_modal.html" %}
|
{% if v %}
|
||||||
|
{% include "award_modal.html" %}
|
||||||
|
{% include "delete_post_modal.html" %}
|
||||||
|
{% endif %}
|
||||||
|
{% include "expanded_image_modal.html" %}
|
||||||
|
{% include "flag_post_modal.html" %}
|
|
@ -62,20 +62,7 @@
|
||||||
t.disabled = true;
|
t.disabled = true;
|
||||||
|
|
||||||
post_toast("/@{{u.username}}/transfer_coins",
|
post_toast("/@{{u.username}}/transfer_coins",
|
||||||
xhr => {
|
false,
|
||||||
if(xhr.status == 200) {
|
|
||||||
fetch("/@{{u.username}}/coins")
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(m => {
|
|
||||||
document.getElementById("profile-coins-amount").innerText = m["coins"];
|
|
||||||
document.getElementById("profile-coins-amount-mobile").innerText = m["coins"];
|
|
||||||
})
|
|
||||||
|
|
||||||
fetch("/@{{v.username}}/coins")
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(m => document.getElementById(`user-coins-amount`).innerText = m["coins"])
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{"amount": document.getElementById(mobile ? "coins-transfer-amount-mobile" : "coins-transfer-amount").value}
|
{"amount": document.getElementById(mobile ? "coins-transfer-amount-mobile" : "coins-transfer-amount").value}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -158,7 +145,13 @@
|
||||||
{% if u.customtitle %}<p class="font-weight-bolder" style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/PCM/quadrants/{{u.quadrant}}.webp">{% endif %}{{u.customtitle | safe}}</p>{% endif %}
|
{% if u.customtitle %}<p class="font-weight-bolder" style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/PCM/quadrants/{{u.quadrant}}.webp">{% endif %}{{u.customtitle | safe}}</p>{% endif %}
|
||||||
|
|
||||||
<div class="font-weight-bolder">
|
<div class="font-weight-bolder">
|
||||||
<span id="profile-coins-amount">{{u.coins}}</span> {{'COINS_NAME' | app_config}} {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}<a href="/@{{u.username}}/followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> {% endif %}joined <span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{u.created_datetime}}">{{u.created_date}}</span>
|
<span id="profile-coins-amount">{{u.coins}}</span>
|
||||||
|
|
||||||
|
<img data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{'COINS_NAME' | app_config}}" height="20" src="https://rdrama.net/assets/images/emojis/marseybux.webp">
|
||||||
|
|
||||||
|
{% if u.stored_subscriber_count >=1 and not u.is_nofollow %}<a href="/@{{u.username}}/followers">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> {% endif %}
|
||||||
|
|
||||||
|
joined <span data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{u.created_datetime}}">{{u.created_date}}</span>
|
||||||
</div>
|
</div>
|
||||||
{% if "pcm" in request.host %}<p class="text-muted">Based Count: {{u.basedcount}}</p>{% endif %}
|
{% if "pcm" in request.host %}<p class="text-muted">Based Count: {{u.basedcount}}</p>{% endif %}
|
||||||
{% if u.bio_html %}
|
{% if u.bio_html %}
|
||||||
|
@ -414,7 +407,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if u.customtitle %}<p style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/PCM/quadrants/{{u.quadrant}}.webp">{% endif %}{{u.customtitle | safe}}</p>{% endif %}
|
{% if u.customtitle %}<p style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/PCM/quadrants/{{u.quadrant}}.webp">{% endif %}{{u.customtitle | safe}}</p>{% endif %}
|
||||||
<div class="font-weight-normal">
|
<div class="font-weight-normal">
|
||||||
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins}}</span> {{'COINS_NAME' | app_config}} {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}<a href="/@{{u.username}}/followers" class="font-weight-bold">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> {% endif %}
|
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins}}</span>
|
||||||
|
|
||||||
|
<img data-toggle="tooltip" data-placement="bottom" title="" data-original-title="{{'COINS_NAME' | app_config}}" height="15" src="https://rdrama.net/assets/images/emojis/marseybux.webp">
|
||||||
|
|
||||||
|
{% if u.stored_subscriber_count >=1 and not u.is_nofollow %}<a href="/@{{u.username}}/followers" class="font-weight-bold">{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}</a> {% endif %}
|
||||||
|
|
||||||
{% if "pcm" in request.host %}
|
{% if "pcm" in request.host %}
|
||||||
<br>Based count: {{u.basedcount}}
|
<br>Based count: {{u.basedcount}}
|
||||||
|
|
|
@ -17,7 +17,7 @@ pyotp
|
||||||
qrcode
|
qrcode
|
||||||
redis
|
redis
|
||||||
requests
|
requests
|
||||||
SQLAlchemy==1.3.19
|
SQLAlchemy
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
pusher_push_notifications
|
pusher_push_notifications
|
||||||
youtube-dl
|
youtube-dl
|
||||||
|
|
Loading…
Reference in New Issue