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 :invalidate_cache
|
||||||
after_create :send_created, unless: :no_webhook_messages
|
after_create :send_created, unless: :no_webhook_messages
|
||||||
|
after_create :initialize_short_url
|
||||||
after_update :update_files, if: :saved_change_to_category?
|
after_update :update_files, if: :saved_change_to_category?
|
||||||
after_update :send_updated, unless: :no_webhook_messages
|
after_update :send_updated, unless: :no_webhook_messages
|
||||||
after_destroy :delete_files
|
after_destroy :delete_files
|
||||||
@ -103,6 +104,10 @@ class APIImage < ApplicationRecord
|
|||||||
ShortUrl.override(md5, url).shorturl
|
ShortUrl.override(md5, url).shorturl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize_short_url
|
||||||
|
ShortUrl.override(md5, url)
|
||||||
|
end
|
||||||
|
|
||||||
def sources_string
|
def sources_string
|
||||||
sources.join("\n")
|
sources.join("\n")
|
||||||
end
|
end
|
||||||
|
@ -23,8 +23,8 @@ class ShortUrl < ApplicationRecord
|
|||||||
def self.override(code, url)
|
def self.override(code, url)
|
||||||
prev = find_by(code: code)
|
prev = find_by(code: code)
|
||||||
return prev if prev&.url == url && prev&.management_code.nil?
|
return prev if prev&.url == url && prev&.management_code.nil?
|
||||||
prev&.update!(code: "#{code}_#{prev.id}")
|
|
||||||
CurrentUser.as_system do
|
CurrentUser.as_system do
|
||||||
|
prev&.update!(code: "#{code}_#{prev.id}")
|
||||||
create!(
|
create!(
|
||||||
code: code,
|
code: code,
|
||||||
creator_name: "YiffyAPI",
|
creator_name: "YiffyAPI",
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
#!/usr/bin/env sh
|
#!/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 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