decord/source/modules/premium/UserOfferActionCreators.tsx

233 lines
8 KiB
TypeScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 6447
2026-07-27 11:26:19 +00:00
// Function ID: 57886
2026-07-20 16:05:17 +00:00
// Name: _fetchUserOffer
2026-07-25 08:10:48 +00:00
// Dependencies: [5, 6160, 1852, 653, 477, 686, 675, 507, 6190, 1184, 3947, 1334, 1331, 2]
2026-07-20 16:05:17 +00:00
// Exports: acknowledgeUserOffer, fetchChurnDiscountOffer, fetchExistingChurnDiscountOffer, fetchUserOffer
2026-07-25 08:10:48 +00:00
// Module 6447 (_fetchUserOffer)
2026-07-23 10:11:24 +00:00
import dispatcher from "dispatcher";
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import { PREMIUM_TIER_2_HFU_TWO_WEEK_TRIAL_ID as closure_5 } from "GuildFeatures";
import ME from "ME";
let closure_6;
let closure_7;
let closure_8;
const require = arg1;
2026-07-20 16:05:17 +00:00
async function _fetchUserOffer(arg0, arg1) {
2026-07-23 10:11:24 +00:00
let iter = (function*(call_location, arg1, arg2, retries) {
2026-07-20 16:05:17 +00:00
let offerId;
let paymentGatewayOverride;
let flag = arg1;
let tmp = arg2;
if (flag === undefined) {
flag = true;
}
if (tmp === undefined) {
let obj = { offerId: undefined, paymentGatewayOverride: undefined };
tmp = obj;
}
yield undefined;
if (flag) {
2026-07-23 10:11:24 +00:00
let obj1 = outer2_1(outer2_2[5]);
2026-07-20 16:05:17 +00:00
obj = { type: "BILLING_USER_OFFER_FETCH_START" };
obj1.dispatch(obj);
if (null != call_location) {
2026-07-23 10:11:24 +00:00
let obj3 = outer2_1(outer2_2[6]);
2026-07-20 16:05:17 +00:00
obj = { call_location };
2026-07-23 10:11:24 +00:00
obj3.track(outer2_6.FETCH_USER_OFFER_STARTED, obj);
2026-07-20 16:05:17 +00:00
}
({ offerId, paymentGatewayOverride } = tmp);
if (undefined !== paymentGatewayOverride) {
let GOOGLE = paymentGatewayOverride;
} else {
2026-07-23 10:11:24 +00:00
let obj5 = outer2_0(outer2_2[4]);
2026-07-20 16:05:17 +00:00
if (obj5.isAndroid()) {
2026-07-23 10:11:24 +00:00
GOOGLE = outer2_8.GOOGLE;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj6 = outer2_0(outer2_2[4]);
2026-07-20 16:05:17 +00:00
GOOGLE = null;
if (obj6.isIOS()) {
2026-07-23 10:11:24 +00:00
GOOGLE = outer2_8.APPLE;
2026-07-20 16:05:17 +00:00
}
}
}
if (null == GOOGLE) {
if (null == offerId) {
obj1 = {};
}
2026-07-23 10:11:24 +00:00
const HTTP = outer2_0(outer2_2[7]).HTTP;
const obj2 = { url: outer2_7.USER_OFFER, body: obj1, rejectWithError: true };
2026-07-20 16:05:17 +00:00
retries = undefined;
if (null != retries) {
retries = retries.retries;
}
obj2.retries = retries;
const tmp28 = yield HTTP.post(obj2);
const user_trial_offer = tmp28.body.user_trial_offer;
let tmp31 = null;
if (null != user_trial_offer) {
tmp31 = user_trial_offer;
}
const user_discount_offer = tmp28.body.user_discount_offer;
let tmp34 = null;
if (null != user_discount_offer) {
tmp34 = user_discount_offer;
}
let trial_id;
if (null != tmp31) {
trial_id = tmp32.trial_id;
}
let tmp41 = tmp40;
2026-07-23 10:11:24 +00:00
if (trial_id === outer2_5) {
2026-07-20 16:05:17 +00:00
obj3 = { location: "user_offer_action_creators" };
2026-07-23 10:11:24 +00:00
tmp41 = !outer2_0(outer2_2[8]).isAndroidTwoWeekTrialsExperimentEnabled(obj3);
const obj11 = outer2_0(outer2_2[8]);
2026-07-20 16:05:17 +00:00
}
if (null != offerId) {
if (null != tmp35) {
if (tmp35.discount_id !== offerId) {
const _Error = Error;
const error = new Error("Returned user discount offer does not match offer ID request parameter");
const obj4 = {};
obj5 = { offer_id: offerId, user_discount_offer: tmp34 };
obj4.extra = obj5;
const merged = Object.assign(arg4);
2026-07-23 10:11:24 +00:00
outer2_1(outer2_2[9]).captureException(error, obj4);
2026-07-20 16:05:17 +00:00
throw error;
}
}
}
let result = tmp50;
if (null == tmp31) {
2026-07-23 10:11:24 +00:00
result = outer2_0(outer2_2[10]).UNSAFE_isDismissibleContentDismissed(outer2_0(outer2_2[11]).DismissibleContent.NAGBAR_NOTICE_PREMIUM_TIER_TWO_TRIAL_ENDING);
const obj13 = outer2_0(outer2_2[10]);
2026-07-20 16:05:17 +00:00
}
if (result) {
2026-07-23 10:11:24 +00:00
const result1 = outer2_0(outer2_2[12]).removeDismissedContent(outer2_0(outer2_2[11]).DismissibleContent.NAGBAR_NOTICE_PREMIUM_TIER_TWO_TRIAL_ENDING);
const obj14 = outer2_0(outer2_2[12]);
2026-07-20 16:05:17 +00:00
}
obj6 = { type: "BILLING_USER_OFFER_FETCH_SUCCESS" };
let tmp60 = null;
if (!tmp41) {
tmp60 = tmp31;
}
obj6.userTrialOffer = tmp60;
let fromServer = null;
if (null != tmp34) {
2026-07-23 10:11:24 +00:00
fromServer = outer2_4.createFromServer(tmp35);
2026-07-20 16:05:17 +00:00
}
obj6.userDiscountOffer = fromServer;
2026-07-23 10:11:24 +00:00
outer2_1(outer2_2[5]).dispatch(obj6);
2026-07-20 16:05:17 +00:00
return true;
}
const obj7 = { payment_gateway: GOOGLE, offer_id: offerId };
obj1 = obj7;
} else {
return false;
}
2026-07-23 10:11:24 +00:00
})();
iter.next();
return iter;
2026-07-20 16:05:17 +00:00
}
async function _fetchExistingChurnDiscountOffer() {
2026-07-23 10:11:24 +00:00
let obj = outer2_1(outer2_2[5]);
2026-07-20 16:05:17 +00:00
obj.dispatch({ type: "BILLING_USER_OFFER_FETCH_START" });
2026-07-23 10:11:24 +00:00
const HTTP = outer2_0(outer2_2[7]).HTTP;
obj = { url: outer2_7.CHURN_USER_OFFER, rejectWithError: true };
2026-07-20 16:05:17 +00:00
const offer = yield HTTP.get(obj).body.offer;
let tmp2 = null;
if (null != offer) {
tmp2 = offer;
}
let fromServer = null;
if (null != tmp2) {
2026-07-23 10:11:24 +00:00
fromServer = outer2_4.createFromServer(tmp2);
2026-07-20 16:05:17 +00:00
}
obj = { type: "BILLING_USER_OFFER_FETCH_SUCCESS", userDiscountOffer: fromServer };
2026-07-23 10:11:24 +00:00
outer2_1(outer2_2[5]).dispatch(obj);
2026-07-20 16:05:17 +00:00
const obj1 = { userDiscountOffer: fromServer };
return obj1;
}
async function _fetchChurnDiscountOffer() {
2026-07-23 10:11:24 +00:00
const HTTP = outer2_0(outer2_2[7]).HTTP;
let obj = { url: outer2_7.CHURN_USER_OFFER, rejectWithError: true };
2026-07-20 16:05:17 +00:00
const offer = yield HTTP.post(obj).body.offer;
let tmp2 = null;
if (null != offer) {
tmp2 = offer;
}
if (null != tmp2) {
2026-07-23 10:11:24 +00:00
const fromServer = outer2_4.createFromServer(tmp2);
2026-07-20 16:05:17 +00:00
obj = { type: "BILLING_USER_OFFER_FETCH_SUCCESS", userDiscountOffer: fromServer };
2026-07-23 10:11:24 +00:00
outer2_1(outer2_2[5]).dispatch(obj);
const obj2 = outer2_1(outer2_2[5]);
2026-07-20 16:05:17 +00:00
}
}
2026-07-23 10:11:24 +00:00
({ AnalyticEvents: closure_6, Endpoints: closure_7, PaymentGateways: closure_8 } = ME);
let result = require("GuildFeatures").fileFinishedImporting("modules/premium/UserOfferActionCreators.tsx");
2026-07-20 16:05:17 +00:00
export const fetchUserOffer = function fetchUserOffer(MobilePremiumOfferManager, arg1, arg2) {
return _fetchUserOffer(...arguments);
};
export const fetchExistingChurnDiscountOffer = function fetchExistingChurnDiscountOffer() {
return _fetchExistingChurnDiscountOffer(...arguments);
};
export const fetchChurnDiscountOffer = function fetchChurnDiscountOffer() {
return _fetchChurnDiscountOffer(...arguments);
};
export const acknowledgeUserOffer = function acknowledgeUserOffer(expires_at, premiumDiscountOffer) {
let id;
if (null != expires_at) {
if (null == expires_at.expires_at) {
id = expires_at.id;
}
}
let id1;
if (null != premiumDiscountOffer) {
if (!premiumDiscountOffer.hasAcknowledged()) {
id1 = premiumDiscountOffer.id;
}
}
2026-07-23 10:11:24 +00:00
const HTTP = require(507) /* _isNativeReflectConstruct */.HTTP;
obj = { url: constants.USER_OFFER_ACKNOWLEDGED, body: obj, oldFormErrors: true, rejectWithError: false };
2026-07-20 16:05:17 +00:00
obj = { user_trial_offer_id: id, user_discount_offer_id: id1 };
const postResult = HTTP.post(obj);
return HTTP.post(obj).then((body) => {
const user_discount = body.body.user_discount;
let tmp = null;
if (null != user_discount) {
tmp = user_discount;
}
const user_discount_offer = body.body.user_discount_offer;
let tmp2 = null;
if (null != user_discount_offer) {
tmp2 = user_discount_offer;
}
2026-07-23 10:11:24 +00:00
let obj = outer1_1(outer1_2[5]);
2026-07-20 16:05:17 +00:00
obj = { type: "BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS" };
const user_trial_offer = body.body.user_trial_offer;
let tmp3 = null;
if (null != user_trial_offer) {
tmp3 = user_trial_offer;
}
obj.userTrialOffer = tmp3;
let fromServer = null;
if (null != tmp) {
2026-07-23 10:11:24 +00:00
fromServer = outer1_4.createFromServer(tmp);
2026-07-20 16:05:17 +00:00
}
obj.userDiscount = fromServer;
let fromServer1 = null;
if (null != tmp2) {
2026-07-23 10:11:24 +00:00
fromServer1 = outer1_4.createFromServer(tmp2);
2026-07-20 16:05:17 +00:00
}
obj.userDiscountOffer = fromServer1;
obj.dispatch(obj);
}).catch((status) => {
if (404 === status.status) {
2026-07-23 10:11:24 +00:00
outer1_1(outer1_2[5]).dispatch({ type: "BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS", userTrialOffer: null, userDiscount: null, userDiscountOffer: null });
const obj = outer1_1(outer1_2[5]);
2026-07-20 16:05:17 +00:00
}
});
};