diff --git a/assets/components/entities/entity.vue b/assets/components/entities/entity.vue index 57048a3d..c1868abd 100644 --- a/assets/components/entities/entity.vue +++ b/assets/components/entities/entity.vue @@ -149,8 +149,15 @@ async function fetchEntity(scroll = true) { this.pageTitle = entity.name; - const campaign = entity.campaigns.find(campaignX => !campaignX.banner); - this.entityUrl = campaign?.url || campaign?.affiliate?.url || entity.url; + const campaign = entity.campaigns.find(campaignX => !campaignX.banner) + || entity.parent?.campaigns.find(campaignX => !campaignX.banner); + + const affiliateParams = new URLSearchParams({ + ...(entity.url && Object.fromEntries(new URL(entity.url).searchParams)), // preserve any query in entity URL, e.g. ?siteId=5 + ...(campaign?.affiliate?.parameters && Object.fromEntries(new URLSearchParams(campaign.affiliate.parameters))), // append affiliate parameters + }).toString(); + + this.entityUrl = campaign?.url || campaign?.affiliate?.url || `${entity.url}${campaign?.affiliate?.parameters ? `?${affiliateParams}` : ''}`; if (scroll && this.$refs.filter?.$el) { this.$refs.filter.$el.scrollIntoView(); diff --git a/assets/js/fragments.js b/assets/js/fragments.js index b675f79d..2322154d 100644 --- a/assets/js/fragments.js +++ b/assets/js/fragments.js @@ -122,6 +122,7 @@ const campaignsFragment = ` affiliate { id url + parameters } banner { id diff --git a/migrations/20190325001339_releases.js b/migrations/20190325001339_releases.js index 49a4d17a..712f3274 100644 --- a/migrations/20190325001339_releases.js +++ b/migrations/20190325001339_releases.js @@ -1285,8 +1285,10 @@ exports.up = knex => Promise.resolve() .inTable('entities'); table.text('url'); + table.text('parameters'); table.unique(['entity_id', 'url']); + table.unique(['entity_id', 'parameters']); table.text('comment'); @@ -1578,6 +1580,12 @@ exports.up = knex => Promise.resolve() CREATE FUNCTION banners_ratio(banner banners) RETURNS numeric AS $$ SELECT ROUND(banner.width::decimal / banner.height::decimal, 2); $$ LANGUAGE SQL STABLE; + + CREATE FUNCTION get_random_campaign() RETURNS SETOF campaigns AS $$ + SELECT * FROM campaigns + ORDER BY random() + LIMIT 1; + $$ LANGUAGE sql STABLE; `); }) // POLICIES @@ -1824,6 +1832,7 @@ exports.down = (knex) => { // eslint-disable-line arrow-body-style DROP POLICY IF EXISTS stashes_policy ON stashes_actors; DROP FUNCTION IF EXISTS current_user_id; + DROP FUNCTION IF EXISTS get_random_campaign; DROP TABLE IF EXISTS releases_search_results; `); diff --git a/public/img/logos/theflourishxxx/theflourishfetish.png b/public/img/logos/theflourishxxx/theflourishfetish.png new file mode 100644 index 00000000..5b9e6204 Binary files /dev/null and b/public/img/logos/theflourishxxx/theflourishfetish.png differ diff --git a/public/img/logos/theflourishxxx/theflourishxxx.png b/public/img/logos/theflourishxxx/theflourishxxx.png new file mode 100644 index 00000000..089a71ff Binary files /dev/null and b/public/img/logos/theflourishxxx/theflourishxxx.png differ diff --git a/seeds/06_affiliates.js b/seeds/06_affiliates.js index bc0a4ddc..57c4aef1 100644 --- a/seeds/06_affiliates.js +++ b/seeds/06_affiliates.js @@ -7,6 +7,12 @@ const affiliates = [ url: 'https://join.archangelvideo.com/track/MzQ3LjEuMS4xLjAuMC4wLjAuMA', comment: 'revshare', }, + { + id: 'kink_params', + network: 'kink', + parameters: 't=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0', + comment: '50%', + }, ]; const banners = [ @@ -465,7 +471,7 @@ const campaigns = [ }, { network: 'kink', - url: 'https://www.kink.com/shoots/latest?t=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0', + affiliate: 'kink_params', comment: '50%', }, { @@ -673,6 +679,7 @@ exports.seed = async knex => Promise.resolve() id: affiliate.id, entity_id: networksBySlug[affiliate.network]?.id || channelsBySlug[affiliate.channel]?.id || null, url: affiliate.url, + parameters: affiliate.parameters, comment: affiliate.comment, }));