Repository navigation
feat: keep code of conduct dms and the web page in sync - #174
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Accepting the code of conduct in one place now updates the other place.
/slack(for example from the email), every code-of-conduct DM they got is replaced with a thank-you./slackopen and accepts in Slack, the page reloads to show the new step.This also fixes the case where a person got two DMs and the second one kept a live button after they accepted in the first.
sequenceDiagram participant S as SlackService participant U as users.slack_coc_messages participant J as SlackCodeOfConductAcceptedJob participant P as /slack page S->>U: post_code_of_conduct remembers {channel, ts} Note over J: accepted in Slack or on /slack J->>U: take all remembered DMs (row lock), clear J->>S: chat.update each DM with the thank-you P->>P: polls GET /slack/status every 5 s P->>P: step changed: reloadChanges
users.slack_coc_messages(jsonb, default[]).SlackService#post_code_of_conductremembers each DM it sends.User#remember_code_of_conduct_message!appends in SQL, so two DMs sent at once are both kept.SlackCodeOfConductAcceptedJobpromotes first (for guests), then replaces every remembered DM plus the DM the acceptance came from. One failed update does not stop the others.User#take_code_of_conduct_messages!reads and clears the list under a row lock. It does not usewith_lock, becauseUser#lock!locks the account.GET /slack/statusreturns{ "step": ... }. A new Stimulus controller (onboarding-status) polls it every 5 seconds on the invite, accept and promotion steps, while the tab is visible, for at most 10 minutes. It reloads the page when the step changes.Not covered
An email cannot be edited after it is sent. The "Sign in and accept" link still works after acceptance, and
/slackthen shows the person as done.Test plan
bundle exec rspec,bin/rails test,bin/rubocop/slack, and check that the DM changes./slack, accept in Slack, and check that the page reloads.This PR has a migration.