Giter VIP home page Giter VIP logo

roleypoly's Introduction

Roleypoly

https://roleypoly.com

Tame your Discord roles.

Need Help with Roleypoly? ๐Ÿ’โ€โ™€๏ธ

๐Ÿ“š Please read through our community documentation.

๐Ÿ˜• Still confused? Talk to us on Discord!

Developing

Roleypoly is a distributed system built with TypeScript, React, Terraform, and Go.

This app is heavily edge computing-based with the backend being deployed via Cloudflare Workers, UI server on Google Cloud Run with 8 regions, and the mention responder in Google Compute Engine.

Extra Development Docs

Quickstart

Option 1 ๐Ÿš€: E2E Dockerized Emulation

This is the fastest way to start. You must be using MacOS or Linux (WSL2 is ok!) for this to be successful.

  • Setup .env using .env.example as a template and guide.
    • When setting up your Discord Application, be sure to set http://localhost:6609/login-callback as the OAuth2 callback URL.
  • Run: yarn install
  • Run: docker-compose up
    • This starts the UI and API servers in hot-reload dev/emulation mode. All changes to TS/TSX files should be properly captured and reloaded for you!
  • Develop you a Roleypoly!

Option 2 ๐Ÿฑโ€๐Ÿ‘ค: Local Emulation

  • With pre-requisites:
    • Node.js 14, Yarn
  • Setup .env using .env.example as a template and guide.
    • When setting up your Discord Application, be sure to set http://localhost:6609/login-callback as the OAuth2 callback URL.
  • Run: yarn install
  • Run: yarn start
    • This starts the Web UI, Storybook, and API servers in hot-reload dev/emulation mode. All changes to TS/TSX files should be properly captured and reloaded for you!
  • Develop you a Roleypoly!

Option 3 ๐Ÿ„๐Ÿค : Wrangler (No emulation)

Outdated. This won't work, but could give you an idea of what to do.

This is probably extremely painful and requires you to have a Cloudflare account.

  • With pre-requisites:

    • Cloudflare Account
    • Node.js 14, Yarn
    • npm i -g @cloudflare/wrangler
      • Do wrangler init, wrangler login, etc...
  • Setup Wrangler for the project

    • Change account_id to your Cloudflare Account ID in wrangler.toml

    • Add a dev environment to wrangler.toml, using .env.example as a reference for how values should be set

      • When setting up your Discord Application, be sure to set http://localhost:8787/login-callback as the OAuth2 callback URL.
      [env.dev]
      
      [env.dev.vars]
      BOT_CLIENT_ID = ...
      UI_PUBLIC_URI = "http://localhost:6601"
      API_PUBLIC_URI = "http://localhost:8787"
      ROOT_USERS = ...
    • wrangler secret put BOT_TOKEN -e dev

    • wrangler secret put BOT_CLIENT_SECRET -e dev

    • Setup KV Namespaces -- Please follow the instructions listed after the command runs.

      • wrangler kvnamespace create -e dev KV_SESSIONS --preview
      • wrangler kvnamespace create -e dev KV_GUILD_DATA --preview
      • wrangler kvnamespace create -e dev KV_GUILDS --preview
  • Setup .env using .env.example as a template and guide.

  • Run yarn install

  • Run both wrangler dev -e dev and yarn start:web

    • This starts the Web UI and API servers in hot-reload dev mode. All changes to TS/TSX files should be properly captured and reloaded for you!
  • Develop you a Roleypoly

    • And get a beer or heated plant because oh no.

Developing Design System Components

For working with the Roleypoly Design System, use the below steps as reference. Code lives in src/design-system among elsewhere.

Run:

  • yarn to install deps
  • yarn start:design-system to open storybook
  • yarn test:design-system to test

Developing Web UI

For working with the Next.js frontend components, use the below steps as reference. Code lives in src/web among elsewhere.

Run:

  • yarn to install deps
  • yarn start:web to run Next.js dev server
  • yarn test:web to test

Developing API Components

For working with the API, use the below steps as reference. Code lives in src/api.

Run:

  • yarn to install deps
  • yarn start:api to start an emulated worker
  • yarn test:api to test

roleypoly's People

Contributors

asleepysheepy avatar dependabot[bot] avatar mekanoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

roleypoly's Issues

Epic: Allowlisting & Blocklisting

For blocklisting, users with a role set as blocklist cannot use the picker UI for that server. This would benefit guilds with mute roles.

For allowlisting, users without a role set as allowlist cannot use the picker UI for that server. This would benefit guilds with gatekeeping roles.

When both are present, blocklist wins.

Logout

Implementation:

  • API
    • POST /revoke-session
      • Calls OAuth2 revoke
      • Deletes session from KV regardless of outcome
  • Web
    • /machinery/logout
      • Fetch call to API
      • Delete cookies, sessionStorage, return to landing

Add loading pages/skeleton states

Currently all Suspense and data-loading states are a white page. A state should be made for generic loading, and possibly skeleton states later.

Integrated role creation

As a role editor, I would like to add roles to my Discord server while editing my server on Roleypoly.

In scope:

  • Inside search picker, allow role creation with no permissions at the last-most position
  • Optional: color picker/palette

Not in scope:

  • Editing roles
  • Deleting roles
  • Reordering roles

Roles not working or appearing correctly

When i need to add another category for roles, it says there is none and the roleypoly role is above the other roles and i needed color roles and one of my mods informed me it wasnโ€™t working and it says the color role is above the roleypoly role even tho it has no permissions to the color roles and the roleypoly role is above them/has all permissions

Change session token generation from ksuid to something less obvious

KSUIDs were used for session keys for speed of development, but we'd rather use something far longer and more random in order to make it exceedingly difficult to hijack sessions. UUIDv4s would be acceptable, but anything is possible. Please tradeoff size vs complexity, as these do get sent in headers, which do have a size limit.

Login

Implementation:

  • API
    • GET /login-bounce
      • Builds Discord OAuth token flow URL, redirects to it
    • GET /login-callback
      • Finishes token flow
      • Gets current user with credential
      • Fetches current user guilds with credentials (fixes #52)
      • Creates a session in KV with token, user, guilds
  • UI
    • /machinery/new-session?id=
      • Sets sessionStorage session_key
      • Sets HTTP-only cookie rp_session_key
      • Redirects to / for reconciliation

Audit Log via Webhooks

As a server manager, I would like to know when changes to Roleypoly occur via the Editor by my fellow server managers, so than I can understand when or why modifications were made.

Acceptance Criteria

  • In the editor "utilities" pane, add an input for a Discord Webhook URL, which is saved to the GuildData KV.
  • Optionally, add an 'audit log' subpage of the guild editor to walk and/or automate through the necessary Webhook setup, which would be able to set and save the webhook URL.
  • On edits, send a detailed notification via the webhook detailing changes, like category modifications, etc, and who did it, if the webhook URL is set.
  • None of this data should be stored, only sent via webhook.

Re-write bot service into Node.js + Discord.js

We originally left Discord.js due to needs around sharding being harder to manage, and some gRPC-ish concerns in an earlier iteration of the bot.

Most of these concerns have been sidelined, as the bot barely does anything of value anymore, and the value available is very well targetted.

Acceptance Criteria

  • /src/discord-bot is made into a node package in packages/bot
  • hack/dockerfiles/bot.Dockerfile updated to use node
  • Go tooling (e.g. CI/CD, go.mod) is removed
  • Functionally and operationally identical to the status quo
    • Not in scope: root commands for stats
  • Must support sharding on a single process

Add dependent roles based on admin set roles

As an administrator with a complicated set of roles, I want to be able to pick roles manually for users and have some other roles automatically assigned to those users based on rules I create.

e.g., I might have a role called Steering Committee Member. A user is on the Steering Committee if they are chair of any committee, an elected delegate, or a member of the executive council. The roles for chair, elected delegate, and exec council are set manually, but I want Roleypoly to set the Steering Committee Member role automatically. If the user in the future has no such required roles, the dependent role should be removed.

This is somewhat related to the allowlist/denylist feature in that we have essentially gated certain roles on others, except that in this case the role is automatically set rather than just being allowed to be added by the user.

Recent Servers in Server Picker/Nav

Store any newly accessed servers in localStorage, sorted by recency.

In Server Nav/Picker, separate a "Recents" area at the top, using data passed down from page-level.

Add more granular setting for category types.

As an editor, I'd like to limit the number of roles selectable within a category so that a user can pick between 1 and any number of roles.

Implementation

Likely change the "category type" selector to match:

  • 0 = Multi (for backwards compatibility)
  • 1 = Single (for backwards compatibility)
  • number = Maximum of N

Shard + third-party status pages

  • Add some basic troubleshooting page for if the bot or web app isn't acting properly
  • Gives 1% more visibility into infrastructure
  • Since shards aren't publicly accessible for a pull-style uptime check, shards should send a heartbeat to the API.

Prelude branch in feat/heartbeat

Auth Redirects

In certain cases, Auth redirects may be necessary.

  • Landing / when authed
  • Server Picker /servers when anonymous
  • Auth Login /auth/login when authed
  • Role Picker /s/[id] when anonymous
  • Server Editor /s/[id]/edit when not editor (will be covered in #82)

Add "Sync from Legacy" utility to Editor

As a server manager, I would like to fetch my categories from Legacy/v1 so that I don't have to set up my roles/categories again.

The API parts of this are present, this covers the manager action button instead of using API.

Add redundant backup on GCP for guild data

Since guild data is the most critical data we hold, lets sync it to GCP somehow.

Possible path, after some exploration:

  • Due to CF Worker config limits re: GCP auth, push GuildData changes to a Cloud Function that stores it in Cloud Storage.
  • Another function for the opposite direction, pulling data out.
  • Add a circuit breaker and/or env flag to make the main worker use GCP "failover store" instead of KV in case of bad stuff.

Bot join flow should redirect to web app after completion.

As a new server manager, I would like to be redirected to the editor when Roleypoly successfully joins via the Discord OAuth flow, so that I can set up my server settings.

Currently, the OAuth flow finishes with a "done!" instead of redirecting.

This would include some configuration changes and Discord app config setting changes to point to the webapp for the redirect.

Epic: Role Picker

Users would be able to pick their roles from an available list of roles.

Roles with dangerous permissions; ADMINISTRATOR, MANAGE_SERVER, MANAGE_ROLES; cannot be selected, and will be disabled.

Roles that are not categorized may not be selected.

Roles in a hidden category may not be selected.

Due to the given nature of these constraints, one would consider doing a whitelist of roles without dangerous permissions and filter any that do not apply.

Deploy to Production

Using Roleypoly bot (current in Legacy Prod)

  • Change Next-Prod bot token to Legacy-Prod
  • Decommission Legacy-Prod (but not Legacy-Stage, as it's doing guild data importing in short-term)
  • Finalize Legacy DB export, put somewhere
  • Import from Legacy DB export instead of using Legacy-Stage, make a ticket to capture.
  • Finally, decommission any unnecessary remaining infrastructure.

Epic: Guild Editor

Guild admins (perms: ADMINISTRATOR and MANAGE_ROLES) would be able to use the editor.

Editor would have a way to categorize roles.

Editor would have a way to create, edit, and sort categories.

Editor would be extensible to support other various modules, such as a blacklist/whitelist system.

Server Listing UX pass

Take a design exploration pass of /servers page

Ideas:

  • Grouped by role (Admin, Manager, User)
  • Icons and boundaries for Recent/All/Groups
  • Favorites? (local only)

Design language changes should also be applied to guilds popover

Access Control settings do not persist

If I set some roles under "Block roles from using Roleypoly" or "Allow these roles to use Roleypoly", press save & exit, and then open that menu again, no roles are listed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.