Merge pull request 'Fixed bug that mods cannot see auto role rules' (#315) from 314 into support
Reviewed-on: sh-edraft.de/kd_discord_bot#315 Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com> Closes #314
This commit is contained in:
commit
c7a1069c0c
@ -2,6 +2,7 @@ from typing import Callable
|
|||||||
|
|
||||||
from ariadne import ObjectType
|
from ariadne import ObjectType
|
||||||
from cpl_core.dependency_injection import ServiceProviderABC
|
from cpl_core.dependency_injection import ServiceProviderABC
|
||||||
|
from cpl_core.type import T
|
||||||
from cpl_discord.service import DiscordBotServiceABC
|
from cpl_discord.service import DiscordBotServiceABC
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ class QueryABC(ObjectType):
|
|||||||
self.set_field(f"{name}Count", lambda *args: wrapper(*args).count())
|
self.set_field(f"{name}Count", lambda *args: wrapper(*args).count())
|
||||||
|
|
||||||
@ServiceProviderABC.inject
|
@ServiceProviderABC.inject
|
||||||
def _can_user_see_element(self, user: AuthUser, element, services: ServiceProviderABC) -> bool:
|
def _can_user_see_element(self, user: AuthUser, element: T, services: ServiceProviderABC) -> bool:
|
||||||
permissions: PermissionService = services.get_service(PermissionService)
|
permissions: PermissionService = services.get_service(PermissionService)
|
||||||
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
bot: DiscordBotServiceABC = services.get_service(DiscordBotServiceABC)
|
||||||
|
|
||||||
@ -82,12 +83,12 @@ class QueryABC(ObjectType):
|
|||||||
break
|
break
|
||||||
|
|
||||||
elif type(element) == AutoRoleRule:
|
elif type(element) == AutoRoleRule:
|
||||||
element: AutoRole = element
|
element: AutoRoleRule = element
|
||||||
for u in user.users:
|
for u in user.users:
|
||||||
u: User = u
|
u: User = u
|
||||||
guild = bot.get_guild(u.server.discord_id)
|
guild = bot.get_guild(u.server.discord_id)
|
||||||
member = guild.get_member(u.discord_id)
|
member = guild.get_member(u.discord_id)
|
||||||
if permissions.is_member_moderator(member) and u.server.id == element.server.id:
|
if permissions.is_member_moderator(member) and u.server.id == element.auto_role.server.id:
|
||||||
access = True
|
access = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user