OperationCode / operationcode_backend

This is the backend repo for the Operation Code website
https://operationcode.org
MIT License
62 stars 110 forks source link

Create new SlackUser Database with RESTful modifications #314

Closed apex-omontgomery closed 6 years ago

apex-omontgomery commented 6 years ago

Feature

Why is this feature being added?

This feature is being added to reduce User table bloat and reduce manual CRUD operations. This modification will create a new table to store Operation Code Slack information and create an endpoint to control the update and secure access for this RESTful endpoint.

Going to be using this issue as the epic for the entire feature, and will attempt to implement as I can.

What should your feature do?

SlackUser Table

key attribute example
FK, unique user_id 20
unique slack_id "W012A3CDE"
slack_name "harry"
slack_real_name "William Michael John"
slack_display_name "Very Unoriginal"
unique slack_email "thebestwrestler@wwf.com"

New User Flow

  1. User creates account through FE or uses previously made account
  2. User creates account in Slack
  3. team_join event triggers some action to the BE with the slack user information
  4. BE finds connected User record and creates a new SlackUser record
  5. If no email found - > request user to set Slack email to be same as OC email.
  6. Notification to change can be a slack message, (preferred). Or an email.

Exisiting User updates

  1. user_change event triggers call to BE repo with information
  2. BE report looks for Slackuser with slack_id, and makes change.
  3. If no SlackUser found, creates new SlackUser and associates with User with matching email
  4. after_update callback on user.email_changed?

BE Endpoints

  1. POST :create -> New User a. success response b. request email update response c. some error status
  2. PUT :update -> Existing User a. success response b. record created c. request email update response d. some error status

API Authentication

  1. Some TBD authentication
hpjaj commented 6 years ago

@wimo7083 - When I wrote this, I was thinking you'd be breaking it out into individual issues. Apologies for not making that clear.

Can you pls create the individual issues for this work?

Issues:

  1. Create SlackUser table and remove column from User table
  2. API authentication for PyBot
  3. Service class to deal with the creating and updating logic of a SlackUser
  4. SlackUser :create and :update endpoints
  5. Idempotent mass update rake task issue
  6. We might also need an after_update callback on user.email_changed?, so let's get a placeholder issue to capture that potential work

Once the issues are created, we can scope out any other missing pieces, associate dependencies with one another, prioritize the tickets, and start banging out the work.

hpjaj commented 6 years ago

Closing this. Thanks for creating all the individual issues.