Merge pull request #10 from HuntingFighter/role-permission-sync

Fixed a bug where permissions were not propagated to fluxer roles
This commit is contained in:
RamBros 2026-03-29 10:26:20 +05:30 committed by GitHub
commit fb773ba948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -132,8 +132,8 @@ async def sync_permissions(context: MigrationContext, progress_callback: Callabl
async def migrate_roles(context: MigrationContext, progress_callback: Callable[[str, int, int], Awaitable[None]] | None = None, force: bool = False) -> list[str]: async def migrate_roles(context: MigrationContext, progress_callback: Callable[[str, int, int], Awaitable[None]] | None = None, force: bool = False) -> list[str]:
"""Copies roles and their baseline permissions. Returns a list of cloned role names.""" """Copies roles and their baseline permissions. Returns a list of cloned role names."""
# Sort roles by position to respect Discord hierarchy # Sort roles by position to respect Discord hierarchy
roles = sorted(await context.discord_reader.get_roles(), key=lambda r: r.position) roles = sorted(await context.discord_reader.get_roles(), key=lambda r: r.position, reverse=True)
if not force: if not force:
roles = [r for r in roles if not context.state.get_fluxer_role_id(str(r.id))] roles = [r for r in roles if not context.state.get_fluxer_role_id(str(r.id))]
@ -148,11 +148,13 @@ async def migrate_roles(context: MigrationContext, progress_callback: Callable[[
break break
logger.debug(f"Creating role: {role.name}") logger.debug(f"Creating role: {role.name}")
# No permission mapping nescessary since fluxer uses the same permission map as discord
fluxer_id = await context.fluxer_writer.create_role( fluxer_id = await context.fluxer_writer.create_role(
name=role.name, name=role.name,
color=role.color.value, color=role.color.value,
hoist=role.hoist, hoist=role.hoist,
mentionable=role.mentionable, mentionable=role.mentionable,
permissions=role.permissions.value,
position=role.position position=role.position
) )
if fluxer_id: if fluxer_id:

View file

@ -388,7 +388,7 @@ class FluxerWriter:
print(f"Failed to send marker: {e}") print(f"Failed to send marker: {e}")
return None return None
async def create_role(self, name: str, color: int, hoist: bool, mentionable: bool, position: Optional[int] = None) -> str: async def create_role(self, name: str, color: int, hoist: bool, mentionable: bool, permissions: int, position: Optional[int] = None) -> str:
""" """
Creates a new role in the Fluxer community. Creates a new role in the Fluxer community.
Returns the new Fluxer role ID. Returns the new Fluxer role ID.
@ -402,6 +402,7 @@ class FluxerWriter:
color=color, color=color,
hoist=hoist, hoist=hoist,
mentionable=mentionable, mentionable=mentionable,
permissions=permissions,
position=position position=position
) )
return str(role["id"]) return str(role["id"])