promo widget validity

This commit is contained in:
SPRINX0\prochazka
2025-10-20 12:54:24 +02:00
parent 59c3381962
commit 5bdf072cdf
3 changed files with 19 additions and 3 deletions

View File

@@ -286,7 +286,14 @@ module.exports = {
premiumPromoWidget_meta: true,
async premiumPromoWidget() {
return getPromoWidgetData();
const data = getPromoWidgetData();
if (data?.state != 'data') {
return null;
}
if (data.validTo && new Date().getTime() > new Date(data.validTo).getTime()) {
return null;
}
return data;
},
// chatStream_meta: {

View File

@@ -271,7 +271,13 @@ async function updatePremiumPromoWidget() {
const tags = (await collectCloudFilesSearchTags()).join(',');
const resp = await axios.default.get(
`${DBGATE_CLOUD_URL}/premium-promo-widget?identifier=${promoWidgetData?.identifier ?? 'nope'}&tags=${tags}`
`${DBGATE_CLOUD_URL}/premium-promo-widget?identifier=${promoWidgetData?.identifier ?? 'empty'}&tags=${tags}`,
{
headers: {
...(await getCloudInstanceHeaders()),
'x-app-version': currentVersion.version,
},
}
);
if (!resp.data || resp.data?.state == 'unchanged') {