foundation: fix exception when uploading new Foundation url format.

Fix 'null value in column "source_url"' exception when uploading urls like this:

* https://foundation.app/@KILLERGF/kgfgen/4
* https://foundation.app/@mochiiimo/foundation/97376
This commit is contained in:
evazion
2022-02-22 13:13:02 -06:00
parent 7b009cc893
commit 112b323f01
4 changed files with 31 additions and 2 deletions

View File

@@ -12,6 +12,10 @@ class UploadMediaAsset < ApplicationRecord
after_create :async_process_upload!
after_save :update_upload_status, if: :saved_change_to_status?
# XXX there are ~150 old assets with blank source urls because the source went bad id before the image url could be saved.
validates :source_url, format: { with: %r{\A(https?|file)://}i, message: "is not a valid URL" }
validates :page_url, format: { with: %r{\A(https?)://}i, message: "is not a valid URL" }, allow_nil: true
enum status: {
pending: 0,
processing: 100,