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 import Blueprint, render_template, abort, redirect, url_for, session, request
 | 
				
			||||||
from flask_babel import gettext
 | 
					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.oauth import generate_guild_icon_url, generate_avatar_url
 | 
				
			||||||
from titanembeds.database import db, Guilds, UserCSS, list_disabled_guilds
 | 
					from titanembeds.database import db, Guilds, UserCSS, list_disabled_guilds
 | 
				
			||||||
from config import config
 | 
					from config import config
 | 
				
			||||||
@@ -60,6 +60,10 @@ def parse_url_domain(url):
 | 
				
			|||||||
    if parsed.netloc != "":
 | 
					    if parsed.netloc != "":
 | 
				
			||||||
        return parsed.netloc
 | 
					        return parsed.netloc
 | 
				
			||||||
    return url
 | 
					    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>")
 | 
					@embed.route("/<int:guild_id>")
 | 
				
			||||||
def guild_embed(guild_id):
 | 
					def guild_embed(guild_id):
 | 
				
			||||||
@@ -93,7 +97,8 @@ def guild_embed(guild_id):
 | 
				
			|||||||
            cssvariables=parse_css_variable(customcss),
 | 
					            cssvariables=parse_css_variable(customcss),
 | 
				
			||||||
            same_target=request.args.get("sametarget", False) == "true",
 | 
					            same_target=request.args.get("sametarget", False) == "true",
 | 
				
			||||||
            userscalable=request.args.get("userscalable", "True").lower().startswith("t"),
 | 
					            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)
 | 
					    abort(404)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@
 | 
				
			|||||||
/* global wdtEmojiBundle */
 | 
					/* global wdtEmojiBundle */
 | 
				
			||||||
/* global EmojiConvertor */
 | 
					/* global EmojiConvertor */
 | 
				
			||||||
/* global post_timeout */
 | 
					/* global post_timeout */
 | 
				
			||||||
 | 
					/* global is_peak */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(function () {
 | 
					(function () {
 | 
				
			||||||
    const theme_options = ["DiscordDark", "FireWyvern", "IceWyvern", "MetroEdge", "BetterTitan"]; // All the avaliable theming names
 | 
					    const theme_options = ["DiscordDark", "FireWyvern", "IceWyvern", "MetroEdge", "BetterTitan"]; // All the avaliable theming names
 | 
				
			||||||
@@ -249,11 +250,13 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // is not in iframe
 | 
					        // is not in iframe
 | 
				
			||||||
        if (!inIframe() || isSameDomain()) {
 | 
					        if ((!inIframe() || isSameDomain()) && !is_peak) {
 | 
				
			||||||
            shouldUtilizeGateway = true;
 | 
					            shouldUtilizeGateway = true;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $(document).on("click focus", enableGateway);
 | 
					            $(document).on("click focus", enableGateway);
 | 
				
			||||||
            $("main").on("mousewheel", enableGateway);
 | 
					            if (!is_peak) {
 | 
				
			||||||
 | 
					                $("main").on("mousewheel", enableGateway);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        $('select').material_select();
 | 
					        $('select').material_select();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -525,6 +525,7 @@
 | 
				
			|||||||
        const post_timeout = {{ guild["post_timeout"]|tojson|safe }};
 | 
					        const post_timeout = {{ guild["post_timeout"]|tojson|safe }};
 | 
				
			||||||
        const visitors_enabled = {% if visitors_enabled %}true{% else %}false{% endif %};
 | 
					        const visitors_enabled = {% if visitors_enabled %}true{% else %}false{% endif %};
 | 
				
			||||||
        const unauth_captcha_enabled = {% if unauth_captcha_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>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <script type="text/javascript" src="{{ url_for('static', filename='js/embed.js') }}"></script>
 | 
					    <script type="text/javascript" src="{{ url_for('static', filename='js/embed.js') }}"></script>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user