Skip to content

Commit

Permalink
Merge branch 'main' into feat/apple_dd_validations
Browse files Browse the repository at this point in the history
  • Loading branch information
kookster committed Sep 19, 2024
2 parents 8344c7a + 5df68d0 commit 13cbcc4
Show file tree
Hide file tree
Showing 77 changed files with 532 additions and 4,660 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ gem "paranoia"
gem "sanitize"

# monitoring/logging
gem "logger"
gem "lograge"
gem "newrelic_rpm"
gem "ougai"
Expand All @@ -72,6 +73,7 @@ gem "aws-sdk-s3"
gem "csv"
gem "excon"
gem "faraday", "~> 0.17.4"
gem "fiddle"
gem "hyperresource"
gem "net-http"
gem "parallel"
Expand All @@ -80,6 +82,7 @@ group :development, :test do
gem "debug", platforms: %i[mri mingw x64_mingw]
gem "dotenv-rails", "~> 2.0"
gem "erb_lint", require: false
gem "ostruct"
gem "pry"
gem "pry-byebug"
gem "standard"
Expand Down
8 changes: 7 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ GEM
loofah (>= 2.3.1)
sax-machine (>= 1.0)
ffi (1.15.5)
fiddle (1.1.2)
fuzzyurl (0.2.2)
globalid (1.2.1)
activesupport (>= 6.1)
Expand Down Expand Up @@ -260,6 +261,7 @@ GEM
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
local_time (2.1.0)
logger (1.6.1)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand Down Expand Up @@ -520,14 +522,15 @@ GEM
opentelemetry-semantic_conventions
opentelemetry-semantic_conventions (1.10.0)
opentelemetry-api (~> 1.0)
ostruct (0.6.0)
ougai (1.9.1)
oj (~> 3.10)
ougai-formatters-customizable (1.0.1)
ougai (~> 1.8, >= 1.8.4)
parallel (1.24.0)
paranoia (2.6.3)
activerecord (>= 5.1, < 7.2)
parser (3.3.3.0)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pg (1.5.4)
Expand Down Expand Up @@ -760,13 +763,15 @@ DEPENDENCIES
factory_bot_rails
faraday (~> 0.17.4)
feedjira
fiddle
hal_api-rails (~> 1.2.2)
hiredis (~> 0.6.3)
hyperresource
importmap-rails
jbuilder
kaminari
local_time
logger
lograge
loofah
minitest-around
Expand All @@ -778,6 +783,7 @@ DEPENDENCIES
opentelemetry-exporter-otlp
opentelemetry-instrumentation-all
opentelemetry-sdk
ostruct
ougai
ougai-formatters-customizable
parallel
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/shared/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ small {
.prx-input-group-text {
background: $white;
color: $gray-600;
text-decoration: none;

&:hover {
text-decoration: none;
Expand Down
44 changes: 44 additions & 0 deletions app/controllers/episode_transcripts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
class EpisodeTranscriptsController < ApplicationController
before_action :set_episode

# GET /episodes/1/transcripts
def show
authorize @episode, :show?

@episode.assign_attributes(episode_params)
@episode.valid?
end

# PATCH/PUT /episodes/1/transcripts
def update
authorize @episode, :update?
@episode.assign_attributes(episode_params)

respond_to do |format|
if @episode.save
@episode.copy_media
format.html { redirect_to episode_transcripts_path(@episode), notice: t(".notice") }
else
flash.now[:error] = t(".error")
format.html { render :show, status: :unprocessable_entity }
end
end
rescue ActiveRecord::StaleObjectError
render :show, status: :conflict
end

private

def set_episode
@episode = Episode.find_by_guid!(params[:episode_id])
@episode.locking_enabled = true
@podcast = @episode.podcast
end

def episode_params
nilify params.fetch(:episode, {}).permit(
:lock_version,
transcript_attributes: %i[id original_url file_size _destroy _retry]
)
end
end
12 changes: 1 addition & 11 deletions app/javascript/controllers/apple_key_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,7 @@ export default class extends Controller {
}

convertKeyToB64(fileText) {
const keyText = this.parseKey(fileText)
const encoded = btoa(keyText)
const encoded = btoa(fileText)
this.pemTarget.value = encoded
}

parseKey(text) {
const strings = text.split("\n")
// remove "begin key" and "end key" text
strings.shift()
strings.pop()

return strings.join("")
}
}
14 changes: 14 additions & 0 deletions app/models/apple/key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Key < ApplicationRecord
validates_presence_of :key_pem_b64

validate :provider_id_is_valid, if: :provider_id?
validate :ec_key_format, if: :key_pem_b64?

def provider_id_is_valid
if provider_id.include?("_")
Expand All @@ -17,5 +18,18 @@ def provider_id_is_valid
def key_pem
Base64.decode64(key_pem_b64)
end

def ec_key_format
unless passes_openssl_validation?
errors.add(:key_pem, "ec key format did not pass OpenSSL validation")
end
end

def passes_openssl_validation?
OpenSSL::PKey::EC.new(key_pem)
true
rescue
false
end
end
end
1 change: 1 addition & 0 deletions app/models/episode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Episode < ApplicationRecord
accepts_nested_attributes_for :contents, allow_destroy: true, reject_if: ->(c) { c[:id].blank? && c[:original_url].blank? }
accepts_nested_attributes_for :images, allow_destroy: true, reject_if: ->(i) { i[:id].blank? && i[:original_url].blank? }
accepts_nested_attributes_for :uncut, allow_destroy: true, reject_if: ->(u) { u[:id].blank? && u[:original_url].blank? }
accepts_nested_attributes_for :transcript, allow_destroy: true, reject_if: ->(t) { t[:id].blank? && t[:original_url].blank? }

validates :podcast_id, :guid, presence: true
validates :title, presence: true
Expand Down
73 changes: 0 additions & 73 deletions app/models/episode_entry_handler.rb

This file was deleted.

117 changes: 0 additions & 117 deletions app/models/episode_story_handler.rb

This file was deleted.

Loading

0 comments on commit 13cbcc4

Please sign in to comment.