Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for generic OAuth dispatching #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dashboard/baserpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .rpc.permissions import DashboardRPC_Permissions
from .rpc.utils import rpccheck
from .rpc.webhooks import DashboardRPC_Webhooks
from .rpc.oauth import DashboardRPC_OAuth

HUMANIZED_PERMISSIONS = {
"view": "View server on dashboard",
Expand Down Expand Up @@ -50,6 +51,7 @@ def __init__(self, cog: commands.Cog):
self.extensions.append(DashboardRPC_Permissions(self.cog))
self.extensions.append(DashboardRPC_AliasCC(self.cog))
self.extensions.append(DashboardRPC_Webhooks(self.cog))
self.extensions.append(DashboardRPC_OAuth(self.cog))

# To make sure that both RPC server and client are on the same "version"
self.version = random.randint(1, 10000)
Expand Down
20 changes: 20 additions & 0 deletions dashboard/rpc/oauth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from redbot.core.bot import Red
from redbot.core.commands import commands

from .utils import rpccheck


class DashboardRPC_OAuth:
def __init__(self, cog: commands.Cog):
self.bot: Red = cog.bot
self.cog: commands.Cog = cog

self.bot.register_rpc_handler(self.oauth_receive)

def unload(self):
self.bot.unregister_rpc_handler(self.oauth_receive)

@rpccheck()
async def oauth_receive(self, user_id: int, payload: dict) -> dict:
self.bot.dispatch("oauth_receive", user_id, payload)
return {"status": 1}