From 8ba486b9ecc7f239ce4dc35ef3be6744f632929d Mon Sep 17 00:00:00 2001 From: Parasprite Date: Thu, 26 Nov 2020 12:35:25 -0600 Subject: [PATCH] Requires link to be origin/content-fanmade Because OC owners be funny like that --- lib/philomena/artist_links/artist_link.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/philomena/artist_links/artist_link.ex b/lib/philomena/artist_links/artist_link.ex index 4e4e1cf4..1cc91307 100644 --- a/lib/philomena/artist_links/artist_link.ex +++ b/lib/philomena/artist_links/artist_link.ex @@ -54,11 +54,21 @@ defmodule Philomena.ArtistLinks.ArtistLink do |> validate_required([:user, :uri, :public]) |> validate_required([:tag], message: "must exist") |> validate_format(:uri, ~r|\Ahttps?://|) + |> validate_category() |> parse_uri() |> put_verification_code() |> put_next_check_at() end + def validate_category(changeset) do + tag = get_field(changeset, :tag) + + case tag.category in ["origin", "content-fanmade"] do + false -> add_error(changeset, :tag, "must be a creator tag") + true -> changeset + end + end + def reject_changeset(artist_link) do change(artist_link, aasm_state: "rejected") end