force create shorturl after image creation

This commit is contained in:
Donovan Daniels 2024-05-08 21:33:45 -05:00
parent 566e334ddd
commit 000e73c56b
Signed by: Donovan_DMC
GPG Key ID: 907D29CBFD6157BA
3 changed files with 9 additions and 1 deletions

View File

@ -17,6 +17,7 @@ class APIImage < ApplicationRecord
after_create :invalidate_cache
after_create :send_created, unless: :no_webhook_messages
after_create :initialize_short_url
after_update :update_files, if: :saved_change_to_category?
after_update :send_updated, unless: :no_webhook_messages
after_destroy :delete_files
@ -103,6 +104,10 @@ class APIImage < ApplicationRecord
ShortUrl.override(md5, url).shorturl
end
def initialize_short_url
ShortUrl.override(md5, url)
end
def sources_string
sources.join("\n")
end

View File

@ -23,8 +23,8 @@ class ShortUrl < ApplicationRecord
def self.override(code, url)
prev = find_by(code: code)
return prev if prev&.url == url && prev&.management_code.nil?
prev&.update!(code: "#{code}_#{prev.id}")
CurrentUser.as_system do
prev&.update!(code: "#{code}_#{prev.id}")
create!(
code: code,
creator_name: "YiffyAPI",

View File

@ -1,2 +1,5 @@
#!/usr/bin/env sh
git pull
docker compose -f docker-compose.prod.yml up -d --no-deps --build
docker compose -f docker-compose.prod.yml restart
nginx -t && nginx -s reload