forked from rDrama/rDrama
merge /chat and /orgy again
parent
bbd80dae21
commit
d089d18e2d
|
@ -28,12 +28,10 @@ let focused = true;
|
|||
let is_typing = false;
|
||||
let alert=true;
|
||||
|
||||
const page_title = document.getElementsByTagName('title')[0].innerHTML;
|
||||
|
||||
function flash(){
|
||||
let title = document.getElementsByTagName('title')[0]
|
||||
if (notifs >= 1 && !focused){
|
||||
title.innerHTML = `[+${notifs}] ${page_title}`;
|
||||
title.innerHTML = `[+${notifs}] Chat`;
|
||||
if (alert) {
|
||||
icon.href = `/i/${site_name}/alert.ico?v=3009`
|
||||
alert=false;
|
||||
|
@ -47,7 +45,7 @@ function flash(){
|
|||
else {
|
||||
icon.href = `/i/${site_name}/icon.webp?x=6`
|
||||
notifs = 0
|
||||
title.innerHTML = page_title;
|
||||
title.innerHTML = 'Chat';
|
||||
}
|
||||
|
||||
if (is_typing) {
|
||||
|
@ -368,21 +366,19 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
box.scrollTo(0, box.scrollHeight)
|
||||
});
|
||||
|
||||
if (location.pathname == '/orgy') {
|
||||
const now = new Date();
|
||||
const day_of_week = now.getUTCDay()
|
||||
const now = new Date();
|
||||
const day_of_week = now.getUTCDay()
|
||||
|
||||
if ([4,5,7].includes(day_of_week)) {
|
||||
let hour
|
||||
if (day_of_week == 7) hour = 20
|
||||
else hour = 0
|
||||
if ([4,5,7].includes(day_of_week)) {
|
||||
let hour
|
||||
if (day_of_week == 7) hour = 20
|
||||
else hour = 0
|
||||
|
||||
let millis = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), hour, 0, 10) - now;
|
||||
if (millis < 0)
|
||||
millis += 86400000;
|
||||
let millis = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), hour, 0, 10) - now;
|
||||
if (millis < 0)
|
||||
millis += 86400000;
|
||||
|
||||
const minutes = Math.round(millis/1000/60*10)/10
|
||||
console.log(`Refreshing page in ${minutes} minutes`)
|
||||
setTimeout(() => location.reload(), millis);
|
||||
}
|
||||
const minutes = Math.round(millis/1000/60*10)/10
|
||||
console.log(`Refreshing page in ${minutes} minutes`)
|
||||
setTimeout(() => location.reload(), millis);
|
||||
}
|
||||
|
|
|
@ -388,7 +388,7 @@ if (is_pwa) {
|
|||
}
|
||||
|
||||
const gbrowser = document.getElementById('gbrowser').value
|
||||
if (location.pathname != '/orgy' && (gbrowser == 'iphone' || gbrowser == 'mac')) {
|
||||
if (location.pathname != '/chat' && (gbrowser == 'iphone' || gbrowser == 'mac')) {
|
||||
const videos = document.querySelectorAll('video')
|
||||
|
||||
for (const video of videos) {
|
||||
|
|
|
@ -423,7 +423,7 @@ function populate_speed_emoji_modal(results, textbox)
|
|||
close_inline_speed_emoji_modal()
|
||||
textbox.value = textbox.value.replace(new RegExp(current_word+"(?=\\s|$)", "gi"), `:${name}: `)
|
||||
textbox.focus()
|
||||
if (!['/chat','/orgy'].includes(location.pathname)) {
|
||||
if (location.pathname != '/chat') {
|
||||
markdown(textbox)
|
||||
}
|
||||
});
|
||||
|
|
|
@ -31,5 +31,6 @@ class Orgy(Base):
|
|||
t += 303
|
||||
return t
|
||||
|
||||
def get_orgy():
|
||||
def get_orgy(v):
|
||||
if not (v and v.allowed_in_chat): return None
|
||||
return g.db.query(Orgy).one_or_none()
|
||||
|
|
|
@ -79,19 +79,19 @@ def cron_fn(every_5m, every_1d, every_fri_12, every_fri_23, every_sat_00, every_
|
|||
g.db.commit()
|
||||
|
||||
if every_fri_12:
|
||||
_create_post(f'Movie Night', f'''Our Movie Night today will show `{get_name()}`.\nThe movie will start at 8 PM EST. [Here is a timezone converter for whoever needs it.](https://dateful.com/time-zone-converter?t=8pm&tz1=EST-EDT-Eastern-Time). You can also check this [countdown timer](https://www.tickcounter.com/countdown/4435809/movie-night) instead.\nIt will be shown [here](/orgy).\nThere will be a 5-minute bathroom break at the 50:00 mark.\nRerun will be Sunday 4 PM EST.''', 11)
|
||||
_create_post(f'Movie Night', f'''Our Movie Night today will show `{get_name()}`.\nThe movie will start at 8 PM EST. [Here is a timezone converter for whoever needs it.](https://dateful.com/time-zone-converter?t=8pm&tz1=EST-EDT-Eastern-Time). You can also check this [countdown timer](https://www.tickcounter.com/countdown/4435809/movie-night) instead.\nIt will be shown [here](/chat).\nThere will be a 5-minute bathroom break at the 50:00 mark.\nRerun will be Sunday 4 PM EST.''', 11)
|
||||
g.db.commit()
|
||||
|
||||
if every_fri_23:
|
||||
_create_post(f'Movie Night in 60 minutes', 'It will be shown [here](/orgy).\nThere will be a 5-minute bathroom break at the 50:00 mark.\nRerun will be Sunday 4 PM EST.', 1)
|
||||
_create_post(f'Movie Night in 60 minutes', 'It will be shown [here](/chat).\nThere will be a 5-minute bathroom break at the 50:00 mark.\nRerun will be Sunday 4 PM EST.', 1)
|
||||
g.db.commit()
|
||||
|
||||
if every_sun_07:
|
||||
_create_post(f'Movie Night Rerun', f'''Our Movie Night Rerun today will show `{get_name()}`.\nThe movie will start at 4 PM EST. [Here is a timezone converter for whoever needs it.](https://dateful.com/time-zone-converter?t=4pm&tz1=EST-EDT-Eastern-Time). You can also check this [countdown timer](https://www.tickcounter.com/countdown/4465675/movie-night-rerun) instead.\nIt will be shown [here](/orgy).\nThere will be a 5-minute bathroom break at the 50:00 mark.''', 1)
|
||||
_create_post(f'Movie Night Rerun', f'''Our Movie Night Rerun today will show `{get_name()}`.\nThe movie will start at 4 PM EST. [Here is a timezone converter for whoever needs it.](https://dateful.com/time-zone-converter?t=4pm&tz1=EST-EDT-Eastern-Time). You can also check this [countdown timer](https://www.tickcounter.com/countdown/4465675/movie-night-rerun) instead.\nIt will be shown [here](/chat).\nThere will be a 5-minute bathroom break at the 50:00 mark.''', 1)
|
||||
g.db.commit()
|
||||
|
||||
if every_sun_19:
|
||||
_create_post(f'Movie Night Rerun in 60 minutes', 'It will be shown [here](/orgy).\nThere will be a 5-minute bathroom break at the 50:00 mark.', 1)
|
||||
_create_post(f'Movie Night Rerun in 60 minutes', 'It will be shown [here](/chat).\nThere will be a 5-minute bathroom break at the 50:00 mark.', 1)
|
||||
g.db.commit()
|
||||
|
||||
if every_sat_00 or every_sun_20:
|
||||
|
@ -154,7 +154,7 @@ def _create_post(title, body, pin_hours):
|
|||
new=False,
|
||||
app_id=None,
|
||||
is_bot=False,
|
||||
url='/orgy',
|
||||
url='/chat',
|
||||
body=body,
|
||||
body_html=body_html,
|
||||
embed=None,
|
||||
|
|
|
@ -1937,7 +1937,7 @@ def admin_reset_password(user_id, v):
|
|||
@app.get("/admin/orgy")
|
||||
@admin_level_required(PERMS['ORGIES'])
|
||||
def orgy_control(v):
|
||||
return render_template("admin/orgy_control.html", v=v, orgy=get_orgy())
|
||||
return render_template("admin/orgy_control.html", v=v, orgy=get_orgy(v))
|
||||
|
||||
@app.post("/admin/start_orgy")
|
||||
@admin_level_required(PERMS['ORGIES'])
|
||||
|
@ -1951,7 +1951,7 @@ def start_orgy(v):
|
|||
if not title:
|
||||
abort(400, "A title is required!")
|
||||
|
||||
if get_orgy():
|
||||
if get_orgy(v):
|
||||
abort(400, "An orgy is already in progress")
|
||||
|
||||
normalized_link = normalize_url(link)
|
||||
|
@ -1978,7 +1978,7 @@ def start_orgy(v):
|
|||
)
|
||||
g.db.add(orgy)
|
||||
|
||||
return redirect('/orgy')
|
||||
return redirect('/chat')
|
||||
|
||||
@app.post("/admin/stop_orgy")
|
||||
@admin_level_required(PERMS['ORGIES'])
|
||||
|
|
|
@ -28,23 +28,19 @@ socketio = SocketIO(
|
|||
sessions = []
|
||||
muted = cache.get(f'muted') or {}
|
||||
|
||||
ALLOWED_REFERRERS = {f'{SITE_FULL}/chat', f'{SITE_FULL}/orgy'}
|
||||
ALLOWED_REFERRERS = {f'{SITE_FULL}/chat'}
|
||||
|
||||
messages = cache.get(f'messages') or {
|
||||
f'{SITE_FULL}/chat': {},
|
||||
f'{SITE_FULL}/orgy': {},
|
||||
}
|
||||
typing = {
|
||||
f'{SITE_FULL}/chat': [],
|
||||
f'{SITE_FULL}/orgy': [],
|
||||
}
|
||||
online = {
|
||||
f'{SITE_FULL}/chat': [],
|
||||
f'{SITE_FULL}/orgy': [],
|
||||
}
|
||||
|
||||
cache.set('loggedin_chat', len(online[f'{SITE_FULL}/chat']), timeout=0)
|
||||
cache.set('loggedin_orgy', len(online[f'{SITE_FULL}/orgy']), timeout=0)
|
||||
|
||||
def auth_required_socketio(f):
|
||||
def wrapper(*args, **kwargs):
|
||||
|
@ -76,31 +72,18 @@ def chat(v):
|
|||
|
||||
displayed_messages = {k: val for k, val in messages[f"{SITE_FULL}/chat"].items() if val["user_id"] not in v.userblocks}
|
||||
|
||||
orgy = get_orgy(v)
|
||||
if orgy:
|
||||
m = md5()
|
||||
with open('files/assets/subtitles.vtt', "rb") as f:
|
||||
data = f.read()
|
||||
m.update(data)
|
||||
subtitles_hash = m.hexdigest()
|
||||
|
||||
return render_template("orgy.html", v=v, messages=displayed_messages, orgy=orgy, subtitles_hash=subtitles_hash)
|
||||
|
||||
return render_template("chat.html", v=v, messages=displayed_messages)
|
||||
|
||||
@app.get("/orgy")
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@auth_required
|
||||
def orgy(v):
|
||||
if not v.allowed_in_chat:
|
||||
abort(403, CHAT_ERROR_MESSAGE)
|
||||
|
||||
orgy = get_orgy()
|
||||
|
||||
displayed_messages = {k: val for k, val in messages[f"{SITE_FULL}/orgy"].items() if val["user_id"] not in v.userblocks}
|
||||
|
||||
if not orgy:
|
||||
return render_template("chat.html", v=v, messages=displayed_messages)
|
||||
|
||||
m = md5()
|
||||
with open('files/assets/subtitles.vtt', "rb") as f:
|
||||
data = f.read()
|
||||
m.update(data)
|
||||
subtitles_hash = m.hexdigest()
|
||||
|
||||
return render_template("orgy.html", v=v, messages=displayed_messages, orgy=orgy, subtitles_hash=subtitles_hash)
|
||||
|
||||
@socketio.on('speak')
|
||||
@is_not_banned_socketio
|
||||
def speak(data, v):
|
||||
|
@ -197,9 +180,7 @@ def speak(data, v):
|
|||
|
||||
def refresh_online():
|
||||
emit("online", [online[request.referrer], muted], room=request.referrer, broadcast=True)
|
||||
|
||||
cache.set('loggedin_chat', len(online[f'{SITE_FULL}/chat']), timeout=0)
|
||||
cache.set('loggedin_orgy', len(online[f'{SITE_FULL}/orgy']), timeout=0)
|
||||
|
||||
@socketio.on('connect')
|
||||
@auth_required_socketio
|
||||
|
|
|
@ -420,3 +420,11 @@ def donate(v):
|
|||
if v and (v.shadowbanned or v.chud == 1 or v.is_permabanned):
|
||||
abort(404)
|
||||
return render_template(f'donate.html', v=v)
|
||||
|
||||
|
||||
@app.get("/orgy")
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
|
||||
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
|
||||
@auth_required
|
||||
def orgy(v):
|
||||
return redirect("/chat")
|
||||
|
|
|
@ -31,13 +31,11 @@ def calc_users():
|
|||
g.loggedin_counter = 0
|
||||
g.loggedout_counter = 0
|
||||
g.loggedin_chat = 0
|
||||
g.loggedin_orgy = 0
|
||||
v = getattr(g, 'v', None) if g else None
|
||||
if has_request_context and g and g.desires_auth and not g.is_api_or_xhr:
|
||||
loggedin = cache.get(LOGGED_IN_CACHE_KEY) or {}
|
||||
loggedout = cache.get(LOGGED_OUT_CACHE_KEY) or {}
|
||||
g.loggedin_chat = cache.get('loggedin_chat') or 0
|
||||
g.loggedin_orgy = cache.get('loggedin_orgy') or 0
|
||||
|
||||
timestamp = int(time.time())
|
||||
|
||||
|
|
|
@ -225,25 +225,15 @@
|
|||
</li>
|
||||
|
||||
{%- if FEATURES['CHAT'] -%}
|
||||
{%- if v and v.allowed_in_chat and get_orgy() -%}
|
||||
<li class="nav-item d-none d-lg-flex align-items-center justify-content-center text-center mx-1" id="header--chat--item">
|
||||
<a class="nav-link position-relative" href="/orgy" style="margin-top: -1.9px !important">
|
||||
<i class="fas fa-tv" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Orgy"></i>
|
||||
<b id="chat-count-header-bar" class="text-lg text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in orgy right now">
|
||||
{{g.loggedin_orgy}}
|
||||
</b>
|
||||
</a>
|
||||
</li>
|
||||
{%- else -%}
|
||||
<li class="nav-item d-none d-lg-flex align-items-center justify-content-center text-center mx-1" id="header--chat--item">
|
||||
<a class="nav-link position-relative" href="/chat" style="margin-top: -1.6px !important">
|
||||
<i class="fas fa-messages" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Chat"></i>
|
||||
<b id="chat-count-header-bar" class="text-lg {% if g.loggedin_chat > 40 %}text-danger{% elif g.loggedin_chat > 20 %}text-yellow{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">
|
||||
{{g.loggedin_chat}}
|
||||
</b>
|
||||
</a>
|
||||
</li>
|
||||
{%- endif -%}
|
||||
<li class="nav-item d-none d-lg-flex align-items-center justify-content-center text-center mx-1" id="header--chat--item">
|
||||
<a class="nav-link position-relative" href="/chat" style="margin-top: -1.6px !important">
|
||||
<i class="fas {% if get_orgy(v) %}
|
||||
fa-tv text-danger{% else %}fa-messages{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Chat"></i>
|
||||
<b id="chat-count-header-bar" class="text-lg {% if g.loggedin_chat > 40 %}text-danger{% elif g.loggedin_chat > 20 %}text-yellow{% endif %}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">
|
||||
{{g.loggedin_chat}}
|
||||
</b>
|
||||
</a>
|
||||
</li>
|
||||
{%- endif -%}
|
||||
|
||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1" id="header--randomuser--item">
|
||||
|
@ -402,7 +392,7 @@
|
|||
</li>
|
||||
{% endif %}
|
||||
<li class="mt-3">
|
||||
{% if request.path in ['/chat', '/orgy'] %}
|
||||
{% if request.path == '/chat' %}
|
||||
<h5 class="ml-3">Users Online</h5>
|
||||
<div id="online3" class="col text-left d-lg-none bg-white mb-6 pb-6" style="max-width:300px"></div>
|
||||
<br><br><br><br>
|
||||
|
|
|
@ -47,25 +47,20 @@
|
|||
</button>
|
||||
{% if v %}
|
||||
{%- if FEATURES['CHAT'] -%}
|
||||
{%- if v and v.allowed_in_chat and get_orgy() -%}
|
||||
<button type="button" class="nobackground border-0 col px-0 btn btn-dead m-0 pt-0" style="margin-right:-10px!important">
|
||||
<a href="/orgy" class="text-decoration-none">
|
||||
<div class="text-center {% if request|selected_tab=='orgy' %}text-primary{% else %}text-muted{% endif %}">
|
||||
<b class="text-lg text-danger" style="padding-top:10px" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in Orgy right now">{{g.loggedin_orgy}}</b>
|
||||
<div class="text-small-extra">Orgy</div>
|
||||
</div>
|
||||
</a>
|
||||
</button>
|
||||
{%- else -%}
|
||||
<button type="button" class="nobackground border-0 col px-0 btn btn-dead m-0 pt-0" style="margin-right:-10px!important">
|
||||
<a href="/chat" class="text-decoration-none">
|
||||
<div class="text-center {% if request|selected_tab=='chat' %}text-primary{% else %}text-muted{% endif %}">
|
||||
<b class="text-lg {% if g.loggedin_chat > 40 %}text-danger{% elif g.loggedin_chat > 20 %}text-yellow{% endif %}" style="padding-top:10px" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">{{g.loggedin_chat}}</b>
|
||||
<div class="text-small-extra">Chat</div>
|
||||
</div>
|
||||
</a>
|
||||
</button>
|
||||
{%- endif -%}
|
||||
<button type="button" class="nobackground border-0 col px-0 btn btn-dead m-0">
|
||||
<a href="/chat" class="text-decoration-none">
|
||||
<div class="text-center {% if request|selected_tab=='chat' %}text-primary{% else %}text-muted{% endif %}">
|
||||
{%- if get_orgy(v) -%}
|
||||
<i class="fas fa-tv text-lg text-danger"></i>
|
||||
{%- else -%}
|
||||
<b class="text-lg {% if g.loggedin_chat > 40 %}text-danger{% elif g.loggedin_chat > 20 %}text-yellow{% endif %}" style="padding-top:10px" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Users in chat right now">
|
||||
{{g.loggedin_chat}}
|
||||
</b>
|
||||
{%- endif -%}
|
||||
<div class="text-small-extra">Chat</div>
|
||||
</div>
|
||||
</a>
|
||||
</button>
|
||||
{%- endif -%}
|
||||
|
||||
{%- if FEATURES['AWARDS'] -%}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{%- extends 'root.html' -%}
|
||||
{% block pagetitle -%}Orgy{%- endblock %}
|
||||
{% block pagetitle -%}Chat{%- endblock %}
|
||||
{% block pagetype %}chat{% endblock %}
|
||||
{% block body_attributes %}class="has_header"{% endblock %}
|
||||
{% block body %}
|
||||
|
|
|
@ -24,10 +24,7 @@ server {
|
|||
proxy_pass http://localhost:5001/chat;
|
||||
include includes/headers;
|
||||
}
|
||||
location /orgy {
|
||||
proxy_pass http://localhost:5001/orgy;
|
||||
include includes/headers;
|
||||
}
|
||||
|
||||
location =/offline.html {
|
||||
alias /d/files/templates/errors/offline.html;
|
||||
include includes/headers;
|
||||
|
|
Loading…
Reference in New Issue