forked from rDrama/rDrama
fix shadowbannedcel post count and comment count
parent
fe894ff917
commit
ac5b58cdb6
|
@ -8,6 +8,7 @@ from sqlalchemy.orm import aliased, deferred, Query
|
||||||
from sqlalchemy.sql import case, func, literal
|
from sqlalchemy.sql import case, func, literal
|
||||||
from sqlalchemy.sql.expression import not_, and_, or_
|
from sqlalchemy.sql.expression import not_, and_, or_
|
||||||
from sqlalchemy.sql.sqltypes import *
|
from sqlalchemy.sql.sqltypes import *
|
||||||
|
from flask import g
|
||||||
|
|
||||||
from files.classes import Base
|
from files.classes import Base
|
||||||
from files.classes.casino_game import CasinoGame
|
from files.classes.casino_game import CasinoGame
|
||||||
|
@ -771,6 +772,19 @@ class User(Base):
|
||||||
return self.profileurl
|
return self.profileurl
|
||||||
return f"{SITE_FULL}/i/default-profile-pic.webp?v=1008"
|
return f"{SITE_FULL}/i/default-profile-pic.webp?v=1008"
|
||||||
|
|
||||||
|
@lazy
|
||||||
|
def real_post_count(self, v):
|
||||||
|
if not self.shadowbanned: return self.post_count
|
||||||
|
if v and (v.id == self.id or v.can_see_shadowbanned): return self.post_count
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@lazy
|
||||||
|
def real_comment_count(self, v):
|
||||||
|
if not self.shadowbanned: return self.comment_count
|
||||||
|
if v and (v.id == self.id or v.can_see_shadowbanned): return self.comment_count
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def json_popover(self, v):
|
def json_popover(self, v):
|
||||||
data = {'username': self.username,
|
data = {'username': self.username,
|
||||||
|
@ -781,8 +795,8 @@ class User(Base):
|
||||||
'bannerurl': self.banner_url,
|
'bannerurl': self.banner_url,
|
||||||
'bio_html': self.bio_html_eager,
|
'bio_html': self.bio_html_eager,
|
||||||
'coins': self.coins,
|
'coins': self.coins,
|
||||||
'post_count': 0 if self.shadowbanned and not (v and v.can_see_shadowbanned) else self.post_count,
|
'post_count': self.real_post_count(v),
|
||||||
'comment_count': 0 if self.shadowbanned and not (v and v.can_see_shadowbanned) else self.comment_count,
|
'comment_count': self.real_comment_count(v),
|
||||||
'badges': [x.path for x in self.badges],
|
'badges': [x.path for x in self.badges],
|
||||||
'created_date': self.created_date,
|
'created_date': self.created_date,
|
||||||
}
|
}
|
||||||
|
@ -818,8 +832,8 @@ class User(Base):
|
||||||
'flair': self.customtitle,
|
'flair': self.customtitle,
|
||||||
'badges': [x.json for x in self.badges],
|
'badges': [x.json for x in self.badges],
|
||||||
'coins': self.coins,
|
'coins': self.coins,
|
||||||
'post_count': self.post_count,
|
'post_count': self.real_post_count(g.v),
|
||||||
'comment_count': self.comment_count
|
'comment_count': self.real_comment_count(g.v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
<a class="nav-link{% if path == '' %} active{% endif %}" href="/@{{u.username}}#content">Wall</a>
|
<a class="nav-link{% if path == '' %} active{% endif %}" href="/@{{u.username}}#content">Wall</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if path == '/posts' %} active{% endif %}" href="/@{{u.username}}/posts#content">Posts <span class="count">({{u.post_count}})</span></a>
|
<a class="nav-link{% if path == '/posts' %} active{% endif %}" href="/@{{u.username}}/posts#content">Posts <span class="count">({{u.real_post_count(v)}})</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link{% if path == '/comments' %} active{% endif %}" href="/@{{u.username}}/comments#content">Comments <span class="count">({{u.comment_count}})</span></a>
|
<a class="nav-link{% if path == '/comments' %} active{% endif %}" href="/@{{u.username}}/comments#content">Comments <span class="count">({{u.real_comment_count(v)}})</span></a>
|
||||||
</li>
|
</li>
|
||||||
{% if u.id == v.id %}
|
{% if u.id == v.id %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
|
|
@ -45,9 +45,9 @@
|
||||||
{{u.stored_subscriber_count}} Followers -
|
{{u.stored_subscriber_count}} Followers -
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if not u.is_private -%}
|
{%- if not u.is_private -%}
|
||||||
{{0 if u.shadowbanned else u.post_count}}
|
{{0 if u.shadowbanned else u.real_post_count(v)}}
|
||||||
Posts -
|
Posts -
|
||||||
{{0 if u.shadowbanned else u.comment_count}}
|
{{0 if u.shadowbanned else u.real_comment_count(v)}}
|
||||||
Comments
|
Comments
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{% if u.bio and (not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned))) %}
|
{% if u.bio and (not u.shadowbanned or (v and (v.id == u.id or v.can_see_shadowbanned))) %}
|
||||||
|
|
Loading…
Reference in New Issue