mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 12:29:30 +02:00
Use user_id shorthand property
This commit is contained in:
@@ -63,8 +63,7 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
user_id = session.get("DISCORD_USER_ID")
|
self.users_cache.pop(self.user_id, None)
|
||||||
self.users_cache.pop(user_id, None)
|
|
||||||
|
|
||||||
for session_key in self.SESSION_KEYS:
|
for session_key in self.SESSION_KEYS:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
from flask import current_app
|
||||||
|
|
||||||
from .base import DiscordModelsBase
|
from .base import DiscordModelsBase
|
||||||
from .integration import Integration
|
from .integration import Integration
|
||||||
from flask import current_app, session
|
|
||||||
|
|
||||||
|
|
||||||
class UserConnection(DiscordModelsBase):
|
class UserConnection(DiscordModelsBase):
|
||||||
@@ -76,7 +77,7 @@ class UserConnection(DiscordModelsBase):
|
|||||||
connections = super().fetch_from_api()
|
connections = super().fetch_from_api()
|
||||||
|
|
||||||
if cache:
|
if cache:
|
||||||
user = current_app.discord.users_cache.get(session.get("DISCORD_USER_ID"))
|
user = current_app.discord.users_cache.get(current_app.discord.user_id)
|
||||||
try:
|
try:
|
||||||
user.connections = connections
|
user.connections = connections
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from flask import current_app, session
|
|
||||||
from .base import DiscordModelsBase
|
from .base import DiscordModelsBase
|
||||||
|
from flask import current_app
|
||||||
from .. import configs
|
from .. import configs
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ class Guild(DiscordModelsBase):
|
|||||||
guilds = super().fetch_from_api()
|
guilds = super().fetch_from_api()
|
||||||
|
|
||||||
if cache:
|
if cache:
|
||||||
user = current_app.discord.users_cache.get(session.get("DISCORD_USER_ID"))
|
user = current_app.discord.users_cache.get(current_app.discord.user_id)
|
||||||
try:
|
try:
|
||||||
user.guilds = {guild.id: guild for guild in guilds}
|
user.guilds = {guild.id: guild for guild in guilds}
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class User(DiscordModelsBase):
|
|||||||
If the current doesn't exists in internal cache.
|
If the current doesn't exists in internal cache.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return current_app.discord.users_cache.get(session.get("DISCORD_USER_ID"))
|
return current_app.discord.users_cache.get(current_app.discord.user_id)
|
||||||
|
|
||||||
def add_to_guild(self, guild_id) -> dict:
|
def add_to_guild(self, guild_id) -> dict:
|
||||||
"""Method to add user to the guild, provided OAuth2 session has already been created with ``guilds.join`` scope.
|
"""Method to add user to the guild, provided OAuth2 session has already been created with ``guilds.join`` scope.
|
||||||
|
|||||||
Reference in New Issue
Block a user