force create shorturl after image creation
This commit is contained in:
parent
566e334ddd
commit
000e73c56b
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user