mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-04 07:47:10 +01:00 
			
		
		
		
	Check for is peak before connecting to gateway
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
from flask import Blueprint, render_template, abort, redirect, url_for, session, request
 | 
			
		||||
from flask_babel import gettext
 | 
			
		||||
from titanembeds.utils import check_guild_existance, guild_query_unauth_users_bool, guild_accepts_visitors, guild_unauthcaptcha_enabled, is_int, redisqueue
 | 
			
		||||
from titanembeds.utils import check_guild_existance, guild_query_unauth_users_bool, guild_accepts_visitors, guild_unauthcaptcha_enabled, is_int, redisqueue, get_online_embed_user_keys
 | 
			
		||||
from titanembeds.oauth import generate_guild_icon_url, generate_avatar_url
 | 
			
		||||
from titanembeds.database import db, Guilds, UserCSS, list_disabled_guilds
 | 
			
		||||
from config import config
 | 
			
		||||
@@ -61,6 +61,10 @@ def parse_url_domain(url):
 | 
			
		||||
        return parsed.netloc
 | 
			
		||||
    return url
 | 
			
		||||
    
 | 
			
		||||
def is_peak(guild_id):
 | 
			
		||||
    usrs = get_online_embed_user_keys(guild_id)
 | 
			
		||||
    return (len(usrs["AuthenticatedUsers"]) + len(usrs["UnauthenticatedUsers"])) > 10
 | 
			
		||||
 | 
			
		||||
@embed.route("/<int:guild_id>")
 | 
			
		||||
def guild_embed(guild_id):
 | 
			
		||||
    if check_guild_existance(guild_id):
 | 
			
		||||
@@ -93,7 +97,8 @@ def guild_embed(guild_id):
 | 
			
		||||
            cssvariables=parse_css_variable(customcss),
 | 
			
		||||
            same_target=request.args.get("sametarget", False) == "true",
 | 
			
		||||
            userscalable=request.args.get("userscalable", "True").lower().startswith("t"),
 | 
			
		||||
            fixed_sidenav=request.args.get("fixedsidenav", "False").lower().startswith("t")
 | 
			
		||||
            fixed_sidenav=request.args.get("fixedsidenav", "False").lower().startswith("t"),
 | 
			
		||||
            is_peak=is_peak(guild_id)
 | 
			
		||||
        )
 | 
			
		||||
    abort(404)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@
 | 
			
		||||
/* global wdtEmojiBundle */
 | 
			
		||||
/* global EmojiConvertor */
 | 
			
		||||
/* global post_timeout */
 | 
			
		||||
/* global is_peak */
 | 
			
		||||
 | 
			
		||||
(function () {
 | 
			
		||||
    const theme_options = ["DiscordDark", "FireWyvern", "IceWyvern", "MetroEdge", "BetterTitan"]; // All the avaliable theming names
 | 
			
		||||
@@ -249,12 +250,14 @@
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // is not in iframe
 | 
			
		||||
        if (!inIframe() || isSameDomain()) {
 | 
			
		||||
        if ((!inIframe() || isSameDomain()) && !is_peak) {
 | 
			
		||||
            shouldUtilizeGateway = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            $(document).on("click focus", enableGateway);
 | 
			
		||||
            if (!is_peak) {
 | 
			
		||||
                $("main").on("mousewheel", enableGateway);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $('select').material_select();
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -525,6 +525,7 @@
 | 
			
		||||
        const post_timeout = {{ guild["post_timeout"]|tojson|safe }};
 | 
			
		||||
        const visitors_enabled = {% if visitors_enabled %}true{% else %}false{% endif %};
 | 
			
		||||
        const unauth_captcha_enabled = {% if unauth_captcha_enabled %}true{% else %}false{% endif %};
 | 
			
		||||
        const is_peak = {{ is_peak|tojson|safe }};
 | 
			
		||||
    </script>
 | 
			
		||||
 | 
			
		||||
    <script type="text/javascript" src="{{ url_for('static', filename='js/embed.js') }}"></script>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user