Update deps & switch to discordrb for webhooks

This commit is contained in:
Donovan Daniels 2025-01-12 18:07:17 -06:00
parent 9e4b59b665
commit f1d4604d1d
No known key found for this signature in database
GPG Key ID: 743DAAE6359EDBA1
19 changed files with 517 additions and 512 deletions

View File

@ -1 +1 @@
3.2.2 3.4.1

View File

@ -1,6 +1,6 @@
FROM ruby:3.2.2-alpine3.18 AS ruby-builder FROM ruby:3.4.1-alpine3.21 AS ruby-builder
RUN apk --no-cache add build-base cmake git glib-dev postgresql14-dev RUN apk --no-cache add build-base cmake git glib-dev postgresql17-dev
COPY Gemfile Gemfile.lock ./ COPY Gemfile Gemfile.lock ./
RUN gem i foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \ RUN gem i foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \
@ -8,17 +8,16 @@ RUN gem i foreman && BUNDLE_IGNORE_CONFIG=true bundle install -j$(nproc) \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \ && find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete && find /usr/local/bundle/gems/ -name "*.o" -delete
FROM node:18-alpine3.18 AS node-builder FROM node:20-alpine3.21 AS node-builder
RUN apk --no-cache add git RUN apk --no-cache add git
WORKDIR /app WORKDIR /app
COPY package.json yarn.lock ./ COPY package.json yarn.lock ./
RUN corepack enable && corepack prepare --activate && yarn install RUN corepack enable && corepack prepare --activate && yarn install --frozen-lockfile
RUN corepack install -g pnpm
FROM ruby:3.2.2-alpine3.18 FROM ruby:3.4.1-alpine3.21
RUN apk --no-cache add ffmpeg vips gifsicle \ RUN apk --no-cache add ffmpeg vips gifsicle \
postgresql14-client \ postgresql17-client \
git git-lfs jemalloc tzdata \ git git-lfs jemalloc tzdata \
openssh-keygen openssh-keygen

28
Gemfile
View File

@ -2,9 +2,9 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "dotenv-rails", require: "dotenv/rails-now" gem "dotenv-rails", require: "dotenv/load"
ruby "3.2.2" ruby "3.4.1"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.1" gem "rails", "~> 7.1.1"
@ -27,12 +27,6 @@ gem "stimulus-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder] # Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder" gem "jbuilder"
# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7" # gem "bcrypt", "~> 3.1.7"
@ -58,20 +52,14 @@ group :development do
# gem "rack-mini-profiler" # gem "rack-mini-profiler"
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring" gem "spring"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
end end
gem "github_webhook", "~> 1.4" gem "github_webhook", "~> 1.4"
gem "httparty", "~> 0.21.0" gem "httparty", "~> 0.22.0"
gem "redis", "~> 5.0" gem "redis", "~> 5.0"
gem "rubocop", "~> 1.57" gem "rubocop", "~> 1.57"
gem "rubocop-erb", "~> 0.3.0" gem "rubocop-erb", "~> 0.5.5"
gem "rubocop-rails", "~> 2.22" gem "rubocop-rails", "~> 2.22"
gem "filesize", "~> 0.2.0" gem "filesize", "~> 0.2.0"
@ -90,7 +78,7 @@ gem "simple_form", "~> 5.3"
gem "responders", "~> 3.1" gem "responders", "~> 3.1"
gem "pagy", "~> 8.3" gem "pagy", "~> 8.6.3"
gem "retriable", "~> 3.1" gem "retriable", "~> 3.1"
@ -103,3 +91,7 @@ gem "opensearch-ruby", "~> 3.3"
gem "good_job", "~> 3.99" gem "good_job", "~> 3.99"
gem "faraday", "~> 2.9" gem "faraday", "~> 2.9"
gem "discordrb-webhooks", "~> 3.5"
gem "next_rails", "~> 1.4"

View File

@ -1,146 +1,148 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.1.1) actioncable (7.1.5.1)
actionpack (= 7.1.1) actionpack (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
actionmailbox (7.1.1) actionmailbox (7.1.5.1)
actionpack (= 7.1.1) actionpack (= 7.1.5.1)
activejob (= 7.1.1) activejob (= 7.1.5.1)
activerecord (= 7.1.1) activerecord (= 7.1.5.1)
activestorage (= 7.1.1) activestorage (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
mail (>= 2.7.1) mail (>= 2.7.1)
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
actionmailer (7.1.1) actionmailer (7.1.5.1)
actionpack (= 7.1.1) actionpack (= 7.1.5.1)
actionview (= 7.1.1) actionview (= 7.1.5.1)
activejob (= 7.1.1) activejob (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
actionpack (7.1.1) actionpack (7.1.5.1)
actionview (= 7.1.1) actionview (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4) rack (>= 2.2.4)
rack-session (>= 1.0.1) rack-session (>= 1.0.1)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
actiontext (7.1.1) actiontext (7.1.5.1)
actionpack (= 7.1.1) actionpack (= 7.1.5.1)
activerecord (= 7.1.1) activerecord (= 7.1.5.1)
activestorage (= 7.1.1) activestorage (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.1.1) actionview (7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.11) erubi (~> 1.11)
rails-dom-testing (~> 2.2) rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6) rails-html-sanitizer (~> 1.6)
activejob (7.1.1) activejob (7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.1.1) activemodel (7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
activerecord (7.1.1) activerecord (7.1.5.1)
activemodel (= 7.1.1) activemodel (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
timeout (>= 0.4.0) timeout (>= 0.4.0)
activestorage (7.1.1) activestorage (7.1.5.1)
actionpack (= 7.1.1) actionpack (= 7.1.5.1)
activejob (= 7.1.1) activejob (= 7.1.5.1)
activerecord (= 7.1.1) activerecord (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
marcel (~> 1.0) marcel (~> 1.0)
activesupport (7.1.1) activesupport (7.1.5.1)
base64 base64
benchmark (>= 0.3)
bigdecimal bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5) connection_pool (>= 2.2.5)
drb drb
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1) minitest (>= 5.1)
mutex_m mutex_m
securerandom (>= 0.3)
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.5) addressable (2.8.7)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2) ast (2.4.2)
aws-eventstream (1.3.0) aws-eventstream (1.3.0)
aws-partitions (1.924.0) aws-partitions (1.1035.0)
aws-sdk-core (3.194.1) aws-sdk-core (3.215.0)
aws-eventstream (~> 1, >= 1.3.0) aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0) aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.8) aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1) jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.80.0) aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.193.0) aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.1) aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.149.0) aws-sdk-s3 (1.177.0)
aws-sdk-core (~> 3, >= 3.194.0) aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1) aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8) aws-sigv4 (~> 1.5)
aws-sigv4 (1.8.0) aws-sigv4 (1.11.0)
aws-eventstream (~> 1, >= 1.0.2) aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0) base64 (0.2.0)
better_html (2.0.2) benchmark (0.4.0)
better_html (2.1.1)
actionview (>= 6.0) actionview (>= 6.0)
activesupport (>= 6.0) activesupport (>= 6.0)
ast (~> 2.0) ast (~> 2.0)
erubi (~> 1.4) erubi (~> 1.4)
parser (>= 2.4) parser (>= 2.4)
smart_properties smart_properties
bigdecimal (3.1.4) bigdecimal (3.1.9)
bindex (0.8.1) bindex (0.8.1)
bootsnap (1.17.0) bootsnap (1.18.4)
msgpack (~> 1.2) msgpack (~> 1.2)
builder (3.2.4) builder (3.3.0)
capybara (3.39.2) concurrent-ruby (1.3.4)
addressable connection_pool (2.5.0)
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crass (1.0.6) crass (1.0.6)
date (3.3.4) csv (3.3.2)
debug (1.8.0) date (3.4.1)
irb (>= 1.5.0) debug (1.10.0)
reline (>= 0.3.1) irb (~> 1.10)
dotenv (2.8.1) reline (>= 0.3.8)
dotenv-rails (2.8.1) discordrb-webhooks (3.5.0)
dotenv (= 2.8.1) rest-client (>= 2.0.0)
railties (>= 3.2) domain_name (0.6.20240107)
drb (2.2.0) dotenv (3.1.7)
ruby2_keywords dotenv-rails (3.1.7)
dotenv (= 3.1.7)
railties (>= 6.1)
drb (2.2.1)
ed25519 (1.3.0) ed25519 (1.3.0)
erubi (1.12.0) erubi (1.13.1)
et-orbi (1.2.11) et-orbi (1.2.11)
tzinfo tzinfo
exifr (1.4.0) exifr (1.4.1)
faraday (2.9.0) faraday (2.12.2)
faraday-net_http (>= 2.0, < 3.2) faraday-net_http (>= 2.0, < 3.5)
faraday-net_http (3.1.0) json
net-http logger
ffi (1.16.3) faraday-net_http (3.4.0)
net-http (>= 0.5.0)
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
filesize (0.2.0) filesize (0.2.0)
fspath (3.1.2) fspath (3.1.2)
fugit (1.11.0) fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11) et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4) raabro (~> 1.4)
github_webhook (1.4.2) github_webhook (1.4.2)
@ -156,32 +158,37 @@ GEM
fugit (>= 1.1) fugit (>= 1.1)
railties (>= 6.0.0) railties (>= 6.0.0)
thor (>= 0.14.1) thor (>= 0.14.1)
httparty (0.21.0) http-accept (1.7.0)
http-cookie (1.0.8)
domain_name (~> 0.5)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0) mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
i18n (1.14.1) i18n (1.14.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
image_optim (0.31.3) image_optim (0.31.4)
exifr (~> 1.2, >= 1.2.2) exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0) fspath (~> 3.0)
image_size (>= 1.5, < 4) image_size (>= 1.5, < 4)
in_threads (~> 1.3) in_threads (~> 1.3)
progress (~> 3.0, >= 3.0.1) progress (~> 3.0, >= 3.0.1)
image_size (3.3.0) image_size (3.4.0)
in_threads (1.6.0) in_threads (1.6.0)
io-console (0.6.0) io-console (0.8.0)
irb (1.8.3) irb (1.14.3)
rdoc rdoc (>= 4.0.0)
reline (>= 0.3.8) reline (>= 0.4.2)
jbuilder (2.11.5) jbuilder (2.13.0)
actionview (>= 5.0.0) actionview (>= 5.0.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
jmespath (1.6.2) jmespath (1.6.2)
jsbundling-rails (1.2.1) jsbundling-rails (1.3.1)
railties (>= 6.0.0) railties (>= 6.0.0)
json (2.6.3) json (2.9.1)
language_server-protocol (3.17.0.3) language_server-protocol (3.17.0.3)
loofah (2.21.4) logger (1.6.5)
loofah (2.24.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.12.0) nokogiri (>= 1.12.0)
mail (2.8.1) mail (2.8.1)
@ -189,184 +196,195 @@ GEM
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
marcel (1.0.2) marcel (1.0.4)
matrix (0.4.2) mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2025.0107)
mini_mime (1.1.5) mini_mime (1.1.5)
minitest (5.20.0) minitest (5.25.4)
msgpack (1.7.2) msgpack (1.7.5)
multi_json (1.15.0) multi_json (1.15.0)
multi_xml (0.6.0) multi_xml (0.7.1)
mutex_m (0.2.0) bigdecimal (~> 3.1)
net-http (0.4.1) mutex_m (0.3.0)
net-http (0.6.0)
uri uri
net-imap (0.4.4) net-imap (0.5.5)
date date
net-protocol net-protocol
net-pop (0.1.2) net-pop (0.1.2)
net-protocol net-protocol
net-protocol (0.2.2) net-protocol (0.2.2)
timeout timeout
net-smtp (0.4.0) net-smtp (0.5.0)
net-protocol netrc (0.11.0)
nio4r (2.5.9) next_rails (1.4.2)
nokogiri (1.15.4-x86_64-linux) rainbow (>= 3)
nio4r (2.7.4)
nokogiri (1.18.1-x86_64-linux-gnu)
racc (~> 1.4) racc (~> 1.4)
opensearch-ruby (3.3.0) nokogiri (1.18.1-x86_64-linux-musl)
racc (~> 1.4)
opensearch-ruby (3.4.0)
faraday (>= 1.0, < 3) faraday (>= 1.0, < 3)
multi_json (>= 1.0) multi_json (>= 1.0)
pagy (8.3.0) pagy (8.6.3)
parallel (1.23.0) parallel (1.26.3)
parser (3.2.2.4) parser (3.3.6.0)
ast (~> 2.4.1) ast (~> 2.4.1)
racc racc
pg (1.5.4) pg (1.5.9)
progress (3.6.0) progress (3.6.0)
psych (5.1.1.1) psych (5.2.2)
date
stringio stringio
public_suffix (5.0.3) public_suffix (6.0.1)
puma (6.4.0) puma (6.5.0)
nio4r (~> 2.0) nio4r (~> 2.0)
raabro (1.4.0) raabro (1.4.0)
racc (1.7.3) racc (1.8.1)
rack (3.0.8) rack (3.1.8)
rack-session (2.0.0) rack-session (2.1.0)
base64 (>= 0.1.0)
rack (>= 3.0.0) rack (>= 3.0.0)
rack-test (2.1.0) rack-test (2.2.0)
rack (>= 1.3) rack (>= 1.3)
rackup (2.1.0) rackup (2.2.1)
rack (>= 3) rack (>= 3)
webrick (~> 1.8) rails (7.1.5.1)
rails (7.1.1) actioncable (= 7.1.5.1)
actioncable (= 7.1.1) actionmailbox (= 7.1.5.1)
actionmailbox (= 7.1.1) actionmailer (= 7.1.5.1)
actionmailer (= 7.1.1) actionpack (= 7.1.5.1)
actionpack (= 7.1.1) actiontext (= 7.1.5.1)
actiontext (= 7.1.1) actionview (= 7.1.5.1)
actionview (= 7.1.1) activejob (= 7.1.5.1)
activejob (= 7.1.1) activemodel (= 7.1.5.1)
activemodel (= 7.1.1) activerecord (= 7.1.5.1)
activerecord (= 7.1.1) activestorage (= 7.1.5.1)
activestorage (= 7.1.1) activesupport (= 7.1.5.1)
activesupport (= 7.1.1)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.1.1) railties (= 7.1.5.1)
rails-dom-testing (2.2.0) rails-dom-testing (2.2.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
minitest minitest
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0) rails-html-sanitizer (1.6.2)
loofah (~> 2.21) loofah (~> 2.21)
nokogiri (~> 1.14) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.1.1) railties (7.1.5.1)
actionpack (= 7.1.1) actionpack (= 7.1.5.1)
activesupport (= 7.1.1) activesupport (= 7.1.5.1)
irb irb
rackup (>= 1.0.0) rackup (>= 1.0.0)
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0, >= 1.2.2) thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
rainbow (3.1.1) rainbow (3.1.1)
rake (13.1.0) rake (13.2.1)
rdoc (6.6.0) rdoc (6.10.0)
psych (>= 4.0.0) psych (>= 4.0.0)
redis (5.0.8) redis (5.3.0)
redis-client (>= 0.17.0) redis-client (>= 0.22.0)
redis-client (0.18.0) redis-client (0.23.1)
connection_pool connection_pool
regexp_parser (2.8.2) regexp_parser (2.10.0)
reline (0.4.0) reline (0.6.0)
io-console (~> 0.5) io-console (~> 0.5)
request_store (1.5.1) request_store (1.7.0)
rack (>= 1.4) rack (>= 1.4)
responders (3.1.1) responders (3.1.1)
actionpack (>= 5.2) actionpack (>= 5.2)
railties (>= 5.2) railties (>= 5.2)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2) retriable (3.1.2)
rexml (3.2.6) rubocop (1.70.0)
rubocop (1.57.2)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0) language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.2.2.4) parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 2.9.3, < 3.0)
rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.36.2, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.30.0) rubocop-ast (1.37.0)
parser (>= 3.2.1.0) parser (>= 3.3.1.0)
rubocop-erb (0.3.0) rubocop-erb (0.5.5)
better_html better_html
rubocop (~> 1.45) rubocop (~> 1.45)
rubocop-rails (2.22.1) rubocop-rails (2.28.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0) rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0) ruby-progressbar (1.13.0)
ruby-vips (2.2.0) ruby-vips (2.2.2)
ffi (~> 1.12) ffi (~> 1.12)
ruby2_keywords (0.0.5) logger
rubyzip (2.3.2) securerandom (0.4.1)
selenium-webdriver (4.15.0) simple_form (5.3.1)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
simple_form (5.3.0)
actionpack (>= 5.2) actionpack (>= 5.2)
activemodel (>= 5.2) activemodel (>= 5.2)
smart_properties (1.17.0) smart_properties (1.17.0)
spring (4.2.1)
sprockets (4.2.1) sprockets (4.2.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4) rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2) sprockets-rails (3.5.2)
actionpack (>= 5.2) actionpack (>= 6.1)
activesupport (>= 5.2) activesupport (>= 6.1)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
stimulus-rails (1.3.0) stimulus-rails (1.3.4)
railties (>= 6.0.0) railties (>= 6.0.0)
stringio (3.0.8) stringio (3.1.2)
thor (1.3.0) thor (1.3.2)
timeout (0.4.1) timeout (0.4.3)
tzinfo (2.0.6) tzinfo (2.0.6)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0) unicode-display_width (3.1.3)
uri (0.13.0) unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
uri (1.0.2)
web-console (4.2.1) web-console (4.2.1)
actionview (>= 6.0.0) actionview (>= 6.0.0)
activemodel (>= 6.0.0) activemodel (>= 6.0.0)
bindex (>= 0.4.0) bindex (>= 0.4.0)
railties (>= 6.0.0) railties (>= 6.0.0)
webrick (1.8.1) websocket-driver (0.7.7)
websocket (1.2.10) base64
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
xpath (3.2.0) zeitwerk (2.7.1)
nokogiri (~> 1.8)
zeitwerk (2.6.12)
PLATFORMS PLATFORMS
x86_64-linux x86_64-linux
x86_64-linux-musl
DEPENDENCIES DEPENDENCIES
addressable (~> 2.8) addressable (~> 2.8)
aws-sdk-s3 (~> 1.149) aws-sdk-s3 (~> 1.149)
bootsnap bootsnap
capybara
debug debug
discordrb-webhooks (~> 3.5)
dotenv-rails dotenv-rails
ed25519 (~> 1.3) ed25519 (~> 1.3)
faraday (~> 2.9) faraday (~> 2.9)
filesize (~> 0.2.0) filesize (~> 0.2.0)
github_webhook (~> 1.4) github_webhook (~> 1.4)
good_job (~> 3.99) good_job (~> 3.99)
httparty (~> 0.21.0) httparty (~> 0.22.0)
image_optim (~> 0.31.3) image_optim (~> 0.31.3)
jbuilder jbuilder
jsbundling-rails jsbundling-rails
next_rails (~> 1.4)
opensearch-ruby (~> 3.3) opensearch-ruby (~> 3.3)
pagy (~> 8.3) pagy (~> 8.6.3)
pg (~> 1.1) pg (~> 1.1)
puma (>= 5.0) puma (>= 5.0)
rails (~> 7.1.1) rails (~> 7.1.1)
@ -375,11 +393,11 @@ DEPENDENCIES
responders (~> 3.1) responders (~> 3.1)
retriable (~> 3.1) retriable (~> 3.1)
rubocop (~> 1.57) rubocop (~> 1.57)
rubocop-erb (~> 0.3.0) rubocop-erb (~> 0.5.5)
rubocop-rails (~> 2.22) rubocop-rails (~> 2.22)
ruby-vips (~> 2.2) ruby-vips (~> 2.2)
selenium-webdriver
simple_form (~> 5.3) simple_form (~> 5.3)
spring
sprockets-rails sprockets-rails
stimulus-rails stimulus-rails
timeout (~> 0.4.1) timeout (~> 0.4.1)
@ -387,7 +405,7 @@ DEPENDENCIES
web-console web-console
RUBY VERSION RUBY VERSION
ruby 3.2.2p53 ruby 3.4.1p0
BUNDLED WITH BUNDLED WITH
2.5.10 2.6.2

View File

@ -188,10 +188,11 @@ module YiffRest
elsif !category_info.find { |c| c.db == category }.sfw elsif !category_info.find { |c| c.db == category }.sfw
color = 0xDC143C color = 0xDC143C
end end
Websites.config.yiffyapi_usage_webhook.execute(embeds: [
{ Websites.config.yiffyapi_usage_webhook.execute do |builder|
title: "V2 API Request", builder.add_embed do |embed|
description: <<~DESC.strip, embed.title = "V2 API Request"
embed.description = <<~DESC
Host: **#{request.host}** Host: **#{request.host}**
Path: **#{request.path}** Path: **#{request.path}**
Category: `#{category}` Category: `#{category}`
@ -201,10 +202,10 @@ module YiffRest
IP: **#{request.remote_ip}** IP: **#{request.remote_ip}**
#{bulk} #{bulk}
DESC DESC
color: color, embed.color = color
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}, end
]) end
end end
def allowed_readonly_actions def allowed_readonly_actions

View File

@ -47,28 +47,18 @@ class E621ThumbnailJob < ApplicationJob
entry.update(expires_at: 5.minutes.from_now) entry.update(expires_at: 5.minutes.from_now)
E621ThumbnailErrorCleanupJob.set(wait: 5.minutes).perform_later(entry) E621ThumbnailErrorCleanupJob.set(wait: 5.minutes).perform_later(entry)
end end
thumb = {} Websites.config.e621_thumbnails_webhook.execute do |builder|
if entry.complete? builder.add_embed do |embed|
thumb = { embed.title = title
thumbnail: { embed.description = <<~DESC
url: entry.url,
},
}
end
Websites.config.e621_thumbnails_webhook.execute({
embeds: [
{
title: title,
description: <<~DESC,
Key: ##{entry.api_key_id} (`#{entry.api_key.application_name}`) Key: ##{entry.api_key_id} (`#{entry.api_key.application_name}`)
Post: [##{entry.post_id}](https://e621.net/posts/#{entry.post_id}) Post: [##{entry.post_id}](https://e621.net/posts/#{entry.post_id})
#{body} #{body}
DESC DESC
color: error ? 0xDC143C : 0x008000, embed.color = error ? 0xDC143C : 0x008000
timestamp: Time.now.iso8601, embed.timestamp = Time.now
**thumb, embed.thumbnail = Discordrb::Webhooks::EmbedThumbnail.new(url: entry.url) if entry.complete?
}, end
], end
})
end end
end end

View File

@ -10,7 +10,7 @@ module DiscordConstants
end end
def include?(flag) def include?(flag)
(@flag & flag) == @flag @flag.allbits?(flag)
end end
STAFF = new(1 << 0, "Discord Employee") STAFF = new(1 << 0, "Discord Employee")

View File

@ -126,7 +126,7 @@ module DiscordInteractions
end end
def get_subcommand(required: false) def get_subcommand(required: false)
opt = options.find { |o| o["type"] == DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND || o["type"] == DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND_GROUP } opt = options.find { |o| [DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND, DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND_GROUP].include?(o["type"]) }
if opt.try(:[], "options") if opt.try(:[], "options")
if opt["options"].length == 1 && opt["type"] == DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND_GROUP if opt["options"].length == 1 && opt["type"] == DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND_GROUP
sub = opt["options"].find { |o| o["type"] == DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND } sub = opt["options"].find { |o| o["type"] == DiscordConstants::ApplicationCommandOptionTypes::SUB_COMMAND }

View File

@ -95,11 +95,10 @@ class RateLimiter
route_ra = expires_route.nil? ? short_window / 1000 : expires_route / 1000 route_ra = expires_route.nil? ? short_window / 1000 : expires_route / 1000
headers["Retry-After"] = route_ra.to_s headers["Retry-After"] = route_ra.to_s
Websites.config.yiffyapi_ratelimit_webhook.execute({ Websites.config.yiffyapi_ratelimit_webhook.execute do |builder|
embeds: [ builder.add_embed do |embed|
{ embed.title = "Rate Limit Exceeded"
title: "Rate Limit Exceeded", embed.description = <<~DESC
description: <<~DESC.strip,
**Host:** **#{domain}** **Host:** **#{domain}**
Path: **#{path}** Path: **#{path}**
Auth: **#{apikey.is_anon? ? 'no' : "Yes (`#{apikey.key}`)"}** Auth: **#{apikey.is_anon? ? 'no' : "Yes (`#{apikey.key}`)"}**
@ -114,11 +113,11 @@ class RateLimiter
\u25fd Bucket: **#{bucket}** \u25fd Bucket: **#{bucket}**
\u25fd Decoded Bucket: **#{Base64.urlsafe_decode64(bucket)}** \u25fd Decoded Bucket: **#{Base64.urlsafe_decode64(bucket)}**
DESC DESC
color: 0xDC143C, embed.color = 0xDC143C
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}, end
], end
})
return [:RATELIMIT_SHORT, { return [:RATELIMIT_SHORT, {
limit: short_limit, limit: short_limit,
remaining: remaining, remaining: remaining,
@ -135,11 +134,10 @@ class RateLimiter
global_ra = expires_global.nil? ? long_window / 1000 : expires_global / 1000 global_ra = expires_global.nil? ? long_window / 1000 : expires_global / 1000
headers["Retry-After"] = global_ra.to_s headers["Retry-After"] = global_ra.to_s
Websites.config.yiffyapi_ratelimit_webhook.execute({ Websites.config.yiffyapi_ratelimit_webhook.execute do |builder|
embeds: [ builder.add_embed do |embed|
{ embed.title = "Rate Limit Exceeded"
title: "Rate Limit Exceeded", embed.description = <<~DESC
description: <<~DESC.strip,
**Host:** **#{domain}** **Host:** **#{domain}**
Path: **#{path}** Path: **#{path}**
Auth: **#{apikey.is_anon? ? 'no' : "Yes (`#{apikey.key}`)"}** Auth: **#{apikey.is_anon? ? 'no' : "Yes (`#{apikey.key}`)"}**
@ -152,11 +150,11 @@ class RateLimiter
\u25fd Reset: **#{global_reset}** \u25fd Reset: **#{global_reset}**
\u25fd Reset After: **#{global_reset_after}** \u25fd Reset After: **#{global_reset_after}**
DESC DESC
color: 0xDC143C, embed.color = 0xDC143C
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}, end
], end
})
return [:RATELIMIT_LONG, { return [:RATELIMIT_LONG, {
limit: long_limit, limit: long_limit,
remaining: global_remaining, remaining: global_remaining,

View File

@ -2,9 +2,6 @@
module Requests module Requests
class DiscordWebhook class DiscordWebhook
include HTTParty
base_uri "https://discord.com/api/webhooks"
attr_reader :id, :token attr_reader :id, :token
def initialize(id:, token:) def initialize(id:, token:)
@ -12,34 +9,14 @@ module Requests
@token = token @token = token
end end
def execute(body) def client
r = self.class.post("/#{id}/#{token}?wait=false", { Discordrb::Webhooks::Client.new(id: id, token: token)
body: body.to_json,
headers: {
"Content-Type" => "application/json",
},
})
Rails.logger.warn("Discord webhook failed: #{r.code} #{r.body}") unless r.success?
r
end end
def edit(message_id, body) delegate :execute, :edit_message, :delete, to: :client
r = self.class.patch("/#{id}/#{token}/#{message_id}?wait=false", {
body: body.to_json,
headers: {
"Content-Type" => "application/json",
},
})
Rails.logger.warn("Discord webhook edit failed: #{r.code} #{r.body}") unless r.success?
r
end
def delete def self.is_deleted(error)
self.class.delete("/#{id}/#{token}") error.instance_of?(RestClient::NotFound) && JSON.parse(error.response.body)["code"] == 10_015
end
def self.is_deleted(response)
response.code == 404 && JSON.parse(response.body)["code"] == 10_015
end end
end end
end end

View File

@ -318,17 +318,16 @@ class APIImage < ApplicationRecord
GREEN_TICK = "<:GreenTick:1235058920762904576>" GREEN_TICK = "<:GreenTick:1235058920762904576>"
RED_TICK = "<:RedTick:1235058898549870724>" RED_TICK = "<:RedTick:1235058898549870724>"
def execute(content) def execute(...)
return unless Rails.env.production? return unless Rails.env.production?
Websites.config.yiffyapi_image_logs_webhook.execute({ Discordrb::Webhooks::Client.new(url: Websites.config.yiffyapi_image_logs_webhook_url).execute(...)
embeds: [content],
})
end end
def send_created def send_created
execute({ execute do |builder|
title: "Image Uploaded", builder.add_embed do |embed|
description: <<~DESC, embed.title = "Image Uploaded"
embed.description = <<~DESC
ID: `#{md5}` ID: `#{md5}`
Category: `#{category}` Category: `#{category}`
Artists: `#{artists.join(', ').presence || '[NONE]'}` Artists: `#{artists.join(', ').presence || '[NONE]'}`
@ -339,15 +338,17 @@ class APIImage < ApplicationRecord
Created At: <t:#{created_at.to_i}> Created At: <t:#{created_at.to_i}>
Updated At: <t:#{updated_at.to_i}> Updated At: <t:#{updated_at.to_i}>
DESC DESC
color: GREEN, embed.color = GREEN
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def send_deleted def send_deleted
execute({ execute do |builder|
title: "Image Deleted", builder.add_embed do |embed|
description: <<~DESC, embed.title = "Image Deleted"
embed.description = <<~DESC
ID: `#{md5}` ID: `#{md5}`
Category: `#{category}` Category: `#{category}`
Artists: `#{artists.join(', ').presence || '[NONE]'}}` Artists: `#{artists.join(', ').presence || '[NONE]'}}`
@ -359,9 +360,10 @@ class APIImage < ApplicationRecord
Created At: <t:#{created_at.to_i}> Created At: <t:#{created_at.to_i}>
Updated At: <t:#{updated_at.to_i}> Updated At: <t:#{updated_at.to_i}>
DESC DESC
color: RED, embed.color = RED
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def check_change(attr, changes) def check_change(attr, changes)
@ -390,28 +392,32 @@ class APIImage < ApplicationRecord
return if changes.empty? return if changes.empty?
changes << "Blame: #{blame}" changes << "Blame: #{blame}"
execute({ execute do |builder|
title: "Image Updated", builder.add_embed do |embed|
description: <<~DESC, embed.title = "Image Updated"
embed.description = <<~DESC
ID: `#{md5}` ID: `#{md5}`
#{changes.join("\n")} #{changes.join("\n")}
DESC DESC
color: YELLOW, embed.color = YELLOW
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def send_converted def send_converted
execute({ execute do |builder|
title: "Image Converted", builder.add_embed do |embed|
description: <<~DESC, embed.title = "Image Converted"
embed.description = <<~DESC
ID: `#{md5}` ID: `#{md5}`
Blame: #{blame} Blame: #{blame}
Converted to external image: #{external_api_image.url} Converted to external image: #{external_api_image.url}
DESC DESC
color: YELLOW, embed.color = YELLOW
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def blame def blame
@ -472,7 +478,7 @@ class APIImage < ApplicationRecord
end end
def self.all_seen def self.all_seen
Cache.fetch("img:all_seen", expires_in: 1.minutes) do Cache.fetch("img:all_seen", expires_in: 1.minute) do
keys = all.map { |img| "yiffy2:stats:image:#{img.md5}" } keys = all.map { |img| "yiffy2:stats:image:#{img.md5}" }
values = Cache.redis.mget(*keys) values = Cache.redis.mget(*keys)
results = {} results = {}

View File

@ -227,16 +227,15 @@ class APIKey < ApplicationRecord
GREEN_TICK = "<:GreenTick:1235058920762904576>" GREEN_TICK = "<:GreenTick:1235058920762904576>"
RED_TICK = "<:RedTick:1235058898549870724>" RED_TICK = "<:RedTick:1235058898549870724>"
def execute(content) def execute(...)
Websites.config.yiffyapi_apikey_logs_webhook.execute({ Websites.config.yiffyapi_apikey_logs_webhook.execute(...)
embeds: [content],
})
end end
def send_created def send_created
execute({ execute do |builder|
title: "API Key ##{id} Created", builder.add_embed do |embed|
description: <<~DESC, embed.title = "API Key ##{id} Created"
embed.description = <<~DESC
Key: `#{key}` Key: `#{key}`
Application: `#{application_name}` Application: `#{application_name}`
Usage: `#{usage}` Usage: `#{usage}`
@ -247,15 +246,17 @@ class APIKey < ApplicationRecord
Services: #{access_string} Services: #{access_string}
Blame: #{blame} Blame: #{blame}
DESC DESC
color: GREEN, embed.color = GREEN
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def send_deleted def send_deleted
execute({ execute do |builder|
title: "API Key ##{id} Deleted", builder.add_embed do |embed|
description: <<~DESC, embed.title = "API Key ##{id} Deleted"
embed.description = <<~DESC
Key: `#{key}` Key: `#{key}`
Application: `#{application_name}` Application: `#{application_name}`
Usage: `#{usage}` Usage: `#{usage}`
@ -266,9 +267,10 @@ class APIKey < ApplicationRecord
Services: #{access_string} Services: #{access_string}
Blame: #{blame} Blame: #{blame}
DESC DESC
color: RED, embed.color = RED
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def check_change(attr, changes) def check_change(attr, changes)
@ -301,12 +303,14 @@ class APIKey < ApplicationRecord
return if changes.empty? return if changes.empty?
changes << "Blame: #{blame}" changes << "Blame: #{blame}"
execute({ execute do |builder|
title: "API Key ##{id} Updated", builder.add_embed do |embed|
description: changes.join("\n"), embed.title = "API Key ##{id} Updated"
color: YELLOW, embed.description = changes.join("\n")
timestamp: Time.now.iso8601, embed.color = YELLOW
}) embed.timestamp = Time.now
end
end
end end
def blame def blame

View File

@ -37,7 +37,7 @@ class ApplicationRecord < ActiveRecord::Base
def belongs_to_creator(options = {}) def belongs_to_creator(options = {})
field = options.delete(:field) || :creator field = options.delete(:field) || :creator
class_eval do class_eval do
belongs_to(field, **options.merge(class_name: "APIUser")) belongs_to(field, **options, class_name: "APIUser")
before_validation(on: :create) do |rec| before_validation(on: :create) do |rec|
rec.send("#{field}_id=", CurrentUser.id) if rec.send("#{field}_id").nil? rec.send("#{field}_id=", CurrentUser.id) if rec.send("#{field}_id").nil?
rec.send("#{field}_ip_addr=", CurrentUser.ip_addr) if rec.respond_to?(:"#{field}_ip_addr=") && rec.send("#{field}_ip_addr").nil? rec.send("#{field}_ip_addr=", CurrentUser.ip_addr) if rec.respond_to?(:"#{field}_ip_addr=") && rec.send("#{field}_ip_addr").nil?

View File

@ -61,16 +61,11 @@ class E621Webhook < ApplicationRecord
Requests::DiscordWebhook.new(id: webhook_id, token: webhook_token) Requests::DiscordWebhook.new(id: webhook_id, token: webhook_token)
end end
def embed(**data) def add_defaults(embed)
{ embed.thumbnail = Discordrb::Webhooks::EmbedThumbnail.new(url: "https://status.e621.ws/icon.png")
thumbnail: { embed.url = "https://status.e621.ws"
url: "https://status.e621.ws/icon.png", embed.timestamp = Time.now
}, embed.color = E621_COLOR
url: "https://status.e621.ws",
timestamp: Time.now.iso8601,
color: E621_COLOR,
**data,
}
end end
def notification_webhook def notification_webhook
@ -78,69 +73,88 @@ class E621Webhook < ApplicationRecord
end end
def send_creation_message def send_creation_message
execute({ execute do |builder|
embeds: [ builder.add_embed do |embed|
embed(title: "E621 Status Check", description: "This webhook has been setup to receive status updates for e621's api#{creator_id.present? ? " by <@#{creator_id}>" : ''}."), add_defaults(embed)
], embed.title = "E621 Status Check"
}) embed.description = "This webhook has been setup to receive status updates for e621's api#{creator_id.present? ? " by <@#{creator_id}>" : ''}."
end
end
notification_webhook.execute({ notification_webhook.execute do |builder|
embeds: [ builder.add_embed do |embed|
embed(title: "Status Check Webhook Added", description: "A status check has been added in the channel **#{channel_id}** of the guild **#{guild_id}**#{creator_id.present? ? " by <@#{creator_id}>" : ''}.", color: SUCCESS_COLOR), add_defaults(embed)
], embed.title = "Status Check Webhook Added"
}) embed.description = "A status check has been added in the channel **#{channel_id}** of the guild **#{guild_id}**#{creator_id.present? ? " by <@#{creator_id}>" : ''}."
embed.color = SUCCESS_COLOR
end
end
end end
def send_deletion_message def send_deletion_message
notification_webhook.execute({ notification_webhook.execute do |builder|
embeds: [ builder.add_embed do |embed|
embed(title: "Status Check Webhook Removed", description: "A status check has been removed in the channel **#{channel_id}** of the guild **#{guild_id}**#{creator_id.present? ? " by <@#{creator_id}>" : ''}.", color: ERROR_COLOR), add_defaults(embed)
], embed.title = "Status Check Webhook Removed"
}) embed.description = "A status check has been removed in the channel **#{channel_id}** of the guild **#{guild_id}**#{creator_id.present? ? " by <@#{creator_id}>" : ''}."
embed.color = ERROR_COLOR
end
end
end end
def send_too_many_guild_message def send_too_many_guild_message
execute({ execute do |builder|
embeds: [ builder.add_embed do |embed|
embed(title: "E621 Status Check", description: "You've already enabled #{MAX_PER_GUILD} status checks in this server. Please delete the other webhooks before adding a new check. This webhook will be automatically deleted.", color: ERROR_COLOR), add_defaults(embed)
], embed.title = "E621 Status Check"
}) embed.description = "You've already enabled #{MAX_PER_GUILD} status checks in this server. Please delete the other webhooks before adding a new check. This webhook will be automatically deleted."
embed.color = ERROR_COLOR
end
end
end end
def send_too_many_channel_message def send_too_many_channel_message
execute({ execute do |builder|
embeds: [ builder.add_embed do |embed|
embed(title: "E621 Status Check", description: "You already have a status check enabled in this channel. Delete the other webhook to use a new webhook. This webhook will be automatically deleted.", color: ERROR_COLOR), add_defaults(embed)
], embed.title = "E621 Status Check"
}) embed.description = "You've already enabled #{MAX_PER_CHANNEL} status checks in this channel. Please delete the other webhooks before adding a new check. This webhook will be automatically deleted."
embed.color = ERROR_COLOR
end
end
end end
def send_update(status) def send_update(status)
status_text = E621Status::STATUS_MESSAGES[status.status] status_text = E621Status::STATUS_MESSAGES[status.status]
fields = [ execute do |builder|
{ name: "Status", value: "#{status.status} #{status_text.present? ? "(#{status_text})" : ''}", inline: true }, builder.add_embed do |embed|
{ name: "State", value: E621Status::STATES[status.state] || (status.available ? "up" : "down"), inline: true }, add_defaults(embed)
] embed.title = "E621 Status Update"
# noinspection RubyMismatchedArgumentType embed.description = "E621's api is **#{status.available ? 'available' : 'unavailable'}**."
fields << { name: "Note", value: status.note, inline: false } if status.note.present? embed.color = status.available ? SUCCESS_COLOR : status.status == 403 ? WARNING_COLOR : ERROR_COLOR
color = status.available ? SUCCESS_COLOR : status.status == 403 ? WARNING_COLOR : ERROR_COLOR embed.timestamp = status.created_at
execute({ embed.footer = Discordrb::Webhooks::EmbedFooter.new(text: "Since")
embeds: [ embed.add_field(name: "Status", value: "#{status.status} #{status_text.present? ? "(#{status_text})" : ''}", inline: true)
embed(title: "E621 Status Update", description: "E621's api is **#{status.available ? 'available' : 'unavailable'}**.", color: color, embed.add_field(name: "State", value: E621Status::STATES[status.state] || (status.available ? "up" : "down"), inline: true)
fields: fields, embed.add_field(name: "Note", value: status.note, inline: false) if status.note.present?
timestamp: status.created_at.iso8601, end
footer: { text: "Since" }), end
],
})
end end
def execute(body) def execute(...)
r = webhook&.execute(body) if webhook.nil?
if webhook.nil? || Requests::DiscordWebhook.is_deleted(r)
@skip_delete_webhook = true @skip_delete_webhook = true
destroy destroy
return nil
end
begin
webhook.execute(...)
rescue RestClient::NotFound
@skip_delete_webhook = true
destroy
nil
end end
r
end end
end end

View File

@ -16,7 +16,7 @@ class ExternalAPIImage < ApplicationRecord
validates :site, inclusion: { in: SITES.map(&:value) } validates :site, inclusion: { in: SITES.map(&:value) }
validate :not_deleted, on: :create validate :not_deleted, on: :create
enum site: SITES.to_h { |s| [s.value, s.value] } enum(:site, SITES.to_h { |s| [s.value, s.value] })
module DataMethods module DataMethods
def url def url

View File

@ -64,16 +64,15 @@ class ShortUrl < ApplicationRecord
YELLOW = 0xFFA500 YELLOW = 0xFFA500
RED = 0xFF0000 RED = 0xFF0000
def execute(content) def execute(...)
Websites.config.yiffyapi_apikey_shortener_webhook.execute({ Websites.config.yiffyapi_apikey_shortener_webhook.execute(...)
embeds: [content],
})
end end
def send_created def send_created
execute({ execute do |builder|
title: "Short URL Created", builder.add_embed do |embed|
description: <<~DESC, embed.title = "Short URL Created"
embed.description = <<~DESC
ID: **#{id}** ID: **#{id}**
Code: **#{code}** Code: **#{code}**
URL: #{url} URL: #{url}
@ -81,23 +80,26 @@ class ShortUrl < ApplicationRecord
User-Agent: **#{creator_ua}** User-Agent: **#{creator_ua}**
Blame: #{blame} Blame: #{blame}
DESC DESC
color: GREEN, embed.color = GREEN
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def send_deleted def send_deleted
execute({ execute do |builder|
title: "Short URL Deleted", builder.add_embed do |embed|
description: <<~DESC, embed.title = "Short URL Deleted"
embed.description = <<~DESC
ID: **#{id}** ID: **#{id}**
Code: **#{code}** Code: **#{code}**
URL: #{url} URL: #{url}
Blame: #{blame} Blame: #{blame}
DESC DESC
color: RED, embed.color = RED
timestamp: Time.now.iso8601, embed.timestamp = Time.now
}) end
end
end end
def check_change(attr, changes) def check_change(attr, changes)
@ -112,12 +114,14 @@ class ShortUrl < ApplicationRecord
return if changes.empty? return if changes.empty?
changes << "Blame: #{blame}" changes << "Blame: #{blame}"
execute({ execute do |builder|
title: "Short URL Updated", builder.add_embed do |embed|
description: changes.join("\n"), embed.title = "Short URL Updated"
color: YELLOW, embed.description = changes.join("\n")
timestamp: Time.now.iso8601, embed.color = YELLOW
}) embed.timestamp = Time.now
end
end
end end
def blame def blame

View File

@ -32,7 +32,7 @@ module Websites
config.time_zone = "Central Time (US & Canada)" config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras") # config.eager_load_paths << Rails.root.join("extras")
# #
config.autoload_paths += Dir[Rails.root.join(Rails.root.join("config/routes/**/"))] config.autoload_paths += Rails.root.glob(Rails.root.join("config/routes/**/"))
config.action_controller.action_on_unpermitted_parameters = :raise config.action_controller.action_on_unpermitted_parameters = :raise
config.action_dispatch.default_headers.clear config.action_dispatch.default_headers.clear

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddExternalAPIImagesGeneratedMd5ColumnAndSiteIndex < ActiveRecord::Migration[7.1] class AddExternalAPIImagesGeneratedMd5ColumnAndSiteIndex < ActiveRecord::Migration[7.1]
def change def change
add_index(:external_api_images, :site) add_index(:external_api_images, :site)

View File

@ -26,7 +26,7 @@ services:
tty: true tty: true
postgres: postgres:
image: postgres:14-alpine image: postgres:17-alpine
volumes: volumes:
- db_data:/var/lib/postgresql/data - db_data:/var/lib/postgresql/data
restart: unless-stopped restart: unless-stopped