Skip to content

Commit

Permalink
WIP: Sup v2 with granular permissions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Mar 4, 2023
1 parent a9655e2 commit c7c761e
Show file tree
Hide file tree
Showing 130 changed files with 1,258 additions and 1,145 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
SLACK_VERIFICATION_TOKEN=
SLACK_SIGNING_SECRET=
STRIPE_API_PUBLISHABLE_KEY=
STRIPE_API_KEY=
GOOGLE_API_CLIENT_ID=
79 changes: 33 additions & 46 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,89 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-02-26 11:12:18 -0500 using RuboCop version 0.81.0.
# on 2023-03-04 13:50:53 -0500 using RuboCop version 0.81.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'slack-sup/api/presenters/channel_presenter.rb'
- 'lib/actions.rb'
- 'lib/api/presenters/channel_presenter.rb'

# Offense count: 2
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'slack-sup/commands/opt.rb'
- 'lib/commands/opt.rb'

# Offense count: 1
Lint/DuplicateMethods:
Exclude:
- 'slack-sup/models/channel.rb'
- 'lib/models/channel.rb'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
Lint/NonDeterministicRequireOrder:
Exclude:
- 'slack-sup.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
Lint/RescueException:
Exclude:
- 'slack-sup/models/user.rb'
- 'lib/models/user.rb'

# Offense count: 1
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'slack-sup/app.rb'
- 'lib/app.rb'

# Offense count: 1
# Configuration parameters: AllowKeywordBlockArguments.
Lint/UnderscorePrefixedVariableName:
Exclude:
- 'slack-sup/app.rb'
- 'lib/app.rb'

# Offense count: 1
Lint/UselessAssignment:
Exclude:
- 'slack-sup/models/user.rb'
- 'lib/models/user.rb'

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'slack-sup/models/user.rb'

# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'slack-sup.rb'
- 'lib/models/user.rb'

# Offense count: 2
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Naming/HeredocDelimiterNaming:
Exclude:
- 'slack-sup/commands/help.rb'
- 'slack-sup/info.rb'
- 'lib/commands/help.rb'
- 'lib/info.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'slack-sup/models/team.rb'
- 'lib/models/team.rb'

# Offense count: 28
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
Naming/MethodParameterName:
Exclude:
- 'slack-sup/app.rb'
- 'slack-sup/commands/set.rb'
- 'slack-sup/models/channel.rb'
- 'slack-sup/models/round_stats.rb'
- 'slack-sup/models/sup.rb'
- 'slack-sup/models/team.rb'
- 'lib/app.rb'
- 'lib/commands/set.rb'
- 'lib/models/channel.rb'
- 'lib/models/round_stats.rb'
- 'lib/models/sup.rb'
- 'lib/models/team.rb'

# Offense count: 1
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
Expand All @@ -101,12 +94,12 @@ Naming/MethodParameterName:
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'slack-sup/models/team.rb'
- 'lib/models/team.rb'

# Offense count: 6
Style/IdenticalConditionalBranches:
Exclude:
- 'slack-sup/commands/set.rb'
- 'lib/commands/set.rb'

# Offense count: 1
Style/MixinUsage:
Expand All @@ -123,24 +116,18 @@ Style/MultilineBlockChain:
# Offense count: 1
Style/MultilineTernaryOperator:
Exclude:
- 'slack-sup/api/endpoints/teams_endpoint.rb'

# Offense count: 23
# Cop supports --auto-correct.
Style/MultilineWhenThen:
Exclude:
- 'slack-sup/commands/set.rb'
- 'lib/api/endpoints/teams_endpoint.rb'

# Offense count: 1
Style/MultipleComparison:
Exclude:
- 'slack-sup/commands/opt.rb'
- 'lib/commands/opt.rb'

# Offense count: 3
Style/NestedTernaryOperator:
Exclude:
- 'slack-sup/commands/opt.rb'
- 'slack-sup/models/team.rb'
- 'lib/commands/opt.rb'
- 'lib/models/team.rb'

# Offense count: 21
# Cop supports --auto-correct.
Expand All @@ -149,9 +136,9 @@ Style/NestedTernaryOperator:
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'slack-sup/models/channel_stats.rb'
- 'slack-sup/models/round.rb'
- 'slack-sup/models/round_stats.rb'
- 'slack-sup/models/stats.rb'
- 'slack-sup/models/team.rb'
- 'slack-sup/models/team_stats.rb'
- 'lib/models/channel_stats.rb'
- 'lib/models/round.rb'
- 'lib/models/round_stats.rb'
- 'lib/models/stats.rb'
- 'lib/models/team.rb'
- 'lib/models/team_stats.rb'
11 changes: 0 additions & 11 deletions DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,3 @@ If Mongoid logging is annoying you.
Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO
```

### Heroku

```
heroku run script/console --app=...
Running `script/console` attached to terminal... up, run.7593
2.2.1 > Team.count
=> 3
```
39 changes: 9 additions & 30 deletions DEV.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
## Development Environment

You may want to watch [Your First Slack Bot Service video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html) first.

### Prerequisites

Ensure that you can build the project and run tests. You will need these.

- [MongoDB](https://docs.mongodb.com/manual/installation/)
- [Firefox](https://www.mozilla.org/firefox/new/)
- [Geckodriver](https://github.com/mozilla/geckodriver), download, `tar vfxz` and move to `/usr/local/bin`
- Ruby 2.3.1
- [Geckodriver](https://github.com/mozilla/geckodriver)
- Ruby 2.7.7

```
bundle install
Expand All @@ -22,22 +20,18 @@ Create a Slack team [here](https://slack.com/create).

### Slack App

Create a test app [here](https://api.slack.com/apps). This gives you a client ID and a client secret.

Under _Features/OAuth & Permissions_, configure the redirect URL to `http://localhost:5000`.
Create a test app [here](https://api.slack.com/apps) from [the manifest](manifest.yml).

Add the following Permission Scope.
Use [ngrok](https://ngrok.com/) to tunnel to `localhost:5000`.

* Add a bot user with the username @bot.
* Choose _Allow users to send Slash commands and messages from the messages tab_ under `App Home`.
* Use `https://....ngrok.io/api/slack/action` for _Interactivity and Shortcuts_.
* Use `https://....ngrok.io` for _Redirect Urls_ in _OAuth & Permissions_.
* Use `https://....ngrok.io/api/slack/event` in _Event Subscriptions_.

### Slack Keys

Create a `.env` file.

```
SLACK_CLIENT_ID=slack_client_id
SLACK_CLIENT_SECRET=slack_client_secret
```
Create a `.env` file from [.env.sample](.env.sample) with at least the Slack keys.

### Stripe Keys

Expand All @@ -59,18 +53,6 @@ $ foreman start

Navigate to [localhost:5000](http://localhost:5000).

### Interactive Buttons

To test interactive buttons locally you need [ngrok](https://ngrok.com) to tunnel to `localhost:5000`.

```
ngrok http 5000
```

This will give you a forwarding HTTPs URL, such as `https://a740cdc9.ngrok.io -> localhost:5000`.

Enter `https://a740cdc9.ngrok.io/api/slack/action/` in the Slack `Interactive Messages` configuration section of your app under `Request Url`.

### Google Calendar Integration

* Create a new project on https://console.developers.google.com
Expand All @@ -79,6 +61,3 @@ Enter `https://a740cdc9.ngrok.io/api/slack/action/` in the Slack `Interactive Me
* Choose `Add Credentials`, accessing `User Data` via `Google Calendar API` via `Web Browser (Javascript)`
* Answer remaining questions and `Create a Client ID`
* Set `GOOGLE_API_CLIENT_ID`



4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ gem 'mailchimp_api_v3'
gem 'mongoid'
gem 'mongoid-scroll'
gem 'newrelic_rpm'
gem 'puma'
gem 'rack-robotz'
gem 'rack-server-pages'
gem 'slack-ruby-bot-server'
gem 'slack-ruby-bot-server-events-app-mentions'
gem 'slack-ruby-bot-server-mailchimp'
gem 'slack-ruby-bot-server-rtm'
gem 'slack-ruby-client'
gem 'stripe', '~> 1.58.0'
gem 'unicorn'
gem 'wannabe_bool'

group :development, :test do
Expand Down
28 changes: 8 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ GEM
console (~> 1.10)
nio4r (~> 2.3)
timers (~> 4.1)
async-io (1.34.3)
async
async-websocket (0.8.0)
async-io
websocket-driver (~> 0.7.0)
bson (4.15.0)
builder (3.2.4)
byebug (11.1.1)
Expand Down Expand Up @@ -114,7 +109,6 @@ GEM
kaminari-grape (1.0.1)
grape
kaminari-core (~> 1.0)
kgio (2.11.3)
mailchimp_api_v3 (0.2.18)
rest-client (~> 2)
mime-types (3.3.1)
Expand Down Expand Up @@ -156,6 +150,8 @@ GEM
parser (2.7.1.0)
ast (~> 2.4.0)
public_suffix (4.0.6)
puma (6.1.0)
nio4r (~> 2.0)
racc (1.6.2)
rack (2.2.6.2)
rack-accept (0.4.5)
Expand All @@ -170,7 +166,6 @@ GEM
rack-test (1.1.0)
rack (>= 1.0, < 3)
rainbow (3.0.0)
raindrops (0.19.1)
rake (12.3.3)
regexp_parser (1.7.0)
reline (0.3.2)
Expand Down Expand Up @@ -215,10 +210,6 @@ GEM
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
slack-ruby-bot (0.16.1)
activesupport
hashie
slack-ruby-client (>= 0.14.0)
slack-ruby-bot-server (1.2.1)
async
foreman
Expand All @@ -230,13 +221,13 @@ GEM
rack-rewrite
rack-server-pages
slack-ruby-client
slack-ruby-bot-server-events (0.3.2)
slack-ruby-bot-server (>= 0.12.0)
slack-ruby-bot-server-events-app-mentions (0.1.1)
slack-ruby-bot-server-events
slack-ruby-bot-server-mailchimp (0.2.0)
mailchimp_api_v3
slack-ruby-bot-server (>= 0.10.0)
slack-ruby-bot-server-rtm (0.2.0)
async-websocket (~> 0.8.0)
slack-ruby-bot (>= 0.12.0)
slack-ruby-bot-server (>= 1.0.0)
slack-ruby-client (0.14.6)
activesupport
faraday (>= 0.9)
Expand All @@ -260,9 +251,6 @@ GEM
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
unicorn (5.5.4)
kgio (~> 2.6)
raindrops (~> 0.7)
vcr (5.1.0)
wannabe_bool (0.7.1)
webmock (3.8.3)
Expand Down Expand Up @@ -298,6 +286,7 @@ DEPENDENCIES
mongoid-scroll
mongoid-shell
newrelic_rpm
puma
rack-robotz
rack-server-pages
rack-test
Expand All @@ -306,13 +295,12 @@ DEPENDENCIES
rubocop
selenium-webdriver
slack-ruby-bot-server
slack-ruby-bot-server-events-app-mentions
slack-ruby-bot-server-mailchimp
slack-ruby-bot-server-rtm
slack-ruby-client
stripe (~> 1.58.0)
stripe-ruby-mock (~> 2.4.1)
timecop
unicorn
vcr
wannabe_bool
webmock
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bundle exec unicorn -p $PORT
web: bundle exec puma -p $PORT
Loading

0 comments on commit c7c761e

Please sign in to comment.