Compare commits

..

No commits in common. "6281842a149a760d1753cbc2d994253390dab85b" and "e28904b791c1baa764d9caf027fc541668a2bca2" have entirely different histories.

7 changed files with 55 additions and 95 deletions

4
package-lock.json generated
View File

@ -1,11 +1,11 @@
{
"name": "traxxx-web",
"version": "0.42.19",
"version": "0.42.18",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "0.42.19",
"version": "0.42.18",
"dependencies": {
"@brillout/json-serializer": "^0.5.8",
"@dicebear/collection": "^7.0.5",

View File

@ -87,7 +87,7 @@
"overrides": {
"vite": "$vite"
},
"version": "0.42.19",
"version": "0.42.18",
"imports": {
"#/*": "./*.js"
}

View File

@ -168,9 +168,6 @@ const entityUrl = (() => {
return null;
}
return entity.affiliateUrl || entity.url;
/*
// affiliate might be inherited, only use full URL when directly associated
if (entity.affiliate?.url && entity.affiliate.entityId === entity.id) {
return entity.affiliate.url;
@ -186,7 +183,6 @@ const entityUrl = (() => {
}
return entity.url;
*/
})();
</script>

View File

@ -1,78 +0,0 @@
function getWatchUrl(scene) {
if (scene.url) {
return scene.url;
}
if (scene.channel && (scene.channel.isIndependent || scene.channel.type === 'network')) {
return scene.channel.url;
}
if (scene.network) {
return scene.network.url;
}
return null;
}
export function getAffiliateSceneUrl(scene) {
const watchUrl = getWatchUrl(scene);
if (!watchUrl) {
return null;
}
if (!scene.affiliate) {
return watchUrl;
}
if (scene.affiliate.url?.includes('/track')
&& scene.affiliate.parameters.scene !== false
&& (!scene.channel.isIndependent || scene.channel.id === scene.affiliate.entityId)) { // standard NATS redirect
const { pathname, search } = new URL(watchUrl);
return `${scene.affiliate.url}${pathname.replace(/^\/trial/, '')}${search}`; // replace needed for Jules Jordan, verify behavior on other sites
}
if (scene.affiliate.parameters.query) { // used by e.g. Bang
const newParams = new URLSearchParams({
...Object.fromEntries(new URL(watchUrl).searchParams),
...Object.fromEntries(new URLSearchParams(scene.affiliate.parameters.query)),
});
return `${watchUrl}?${newParams.toString()}`;
}
return watchUrl;
}
export function getAffiliateEntityUrl(entity) {
if (!entity.affiliate) {
return entity.url;
}
if (entity.id === entity.affiliate.entityId) {
return entity.affiliate.url;
}
if (entity.isIndependent) {
return entity.url;
}
if (entity.affiliate.url?.includes('/track')
&& entity.affiliate.parameters.channel !== false) {
const { pathname, search } = new URL(entity.url);
return `${entity.affiliate.url}${pathname.replace(/^\/trial/, '')}${search}`; // replace needed for Jules Jordan, verify behavior on other sites
}
if (entity.affiliate.parameters.query) { // used by e.g. Bang
const newParams = new URLSearchParams({
...Object.fromEntries(new URL(entity.url).searchParams),
...Object.fromEntries(new URLSearchParams(entity.affiliate.parameters.query)),
});
return `${entity.url}?${newParams.toString()}`;
}
return entity.url;
}

View File

@ -2,7 +2,6 @@ import knex from './knex.js';
import redis from './redis.js';
import initLogger from './logger.js';
import entityPrefixes from './entities-prefixes.js';
import { getAffiliateEntityUrl } from './affiliates.js';
const logger = initLogger();
@ -11,7 +10,7 @@ export function curateEntity(entity, context) {
return null;
}
const curatedEntity = {
return {
id: entity.id,
name: entity.name,
slug: entity.slug,
@ -30,7 +29,7 @@ export function curateEntity(entity, context) {
id: entity.affiliate.id,
entityId: entity.affiliate.entity_id,
url: entity.affiliate.url,
parameters: entity.affiliate.parameters || {},
parameters: entity.affiliate.parameters,
} : null,
...context?.append?.[entity.id],
alerts: {
@ -38,10 +37,6 @@ export function curateEntity(entity, context) {
multi: context?.alerts?.filter((alert) => !alert.is_only).flatMap((alert) => alert.alert_ids) || [],
},
};
curatedEntity.affiliateUrl = getAffiliateEntityUrl(curatedEntity, curatedEntity);
return curatedEntity;
}
export async function fetchEntities(options = {}) {

View File

@ -1,4 +1,5 @@
import config from 'config';
import util from 'util'; /* eslint-disable-line no-unused-vars */
import { MerkleJson } from 'merkle-json';
import { knexQuery as knex, knexOwner, knexManticore } from './knex.js';
@ -14,11 +15,57 @@ import escape from '../utils/escape-manticore.js';
import promiseProps from '../utils/promise-props.js';
import initLogger from './logger.js';
import { curateRevision } from './revisions.js';
import { getAffiliateSceneUrl } from './affiliates.js';
const logger = initLogger();
const mj = new MerkleJson();
function getWatchUrl(scene) {
if (scene.url) {
return scene.url;
}
if (scene.channel && (scene.channel.isIndependent || scene.channel.type === 'network')) {
return scene.channel.url;
}
if (scene.network) {
return scene.network.url;
}
return null;
}
function getAffiliateUrl(scene) {
const watchUrl = getWatchUrl(scene);
if (!watchUrl) {
return null;
}
if (!scene.affiliate) {
return watchUrl;
}
if (scene.affiliate.url?.includes('/track')
&& scene.affiliate.parameters.scene !== false
&& (!scene.channel.isIndependent || scene.channel.id === scene.affiliate.entityId)) { // standard NATS redirect
const { pathname, search } = new URL(watchUrl);
return `${scene.affiliate.url}${pathname.replace(/^\/trial/, '')}${search}`; // replace needed for Jules Jordan, verify behavior on other sites
}
if (scene.affiliate.parameters.query) { // used by e.g. Bang
const newParams = new URLSearchParams({
...Object.fromEntries(new URL(watchUrl).searchParams),
...Object.fromEntries(new URLSearchParams(scene.affiliate.parameters.query)),
});
return `${watchUrl}?${newParams.toString()}`;
}
return watchUrl;
}
function curateScene(rawScene, assets) {
if (!rawScene) {
return null;
@ -117,7 +164,7 @@ function curateScene(rawScene, assets) {
isNew: assets.lastBatchId === rawScene.created_batch_id,
};
curatedScene.watchUrl = getAffiliateSceneUrl(curatedScene);
curatedScene.watchUrl = getAffiliateUrl(curatedScene);
return curatedScene;
}

2
static

@ -1 +1 @@
Subproject commit 8ba0b203fad2fa85624590a2547c1ae71f8fb481
Subproject commit 323fb4c9220637d48a1f7516bbfbfafdfdb45ccc