// Metro module 8918 (f8919). import UserStore from "../stores/UserStore"; import { AbortCodes, Endpoints, RelationshipTypes } from "../Constants"; import { ClearFriendRequestFilters } from "../modules/relationships/RelationshipConstants"; import { closeContextMenu } from "./ContextMenuActionCreators"; import AlertActionCreators from "./AlertActionCreators"; import openQuarantineModeInfoModal_native from "../modules/quarantine/openQuarantineModeInfoModal.native"; import { intl, t } from "../intl/index.native"; import { openClaimAccountModal } from "../modules/claim_account/ClaimAccountModalActionCreators.native"; import { isLimitedAccessErrorCode } from "../modules/user_limited_access/UserLimitedAccessUtils"; import { humanizeAbortCode } from "../utils/FriendsUtils"; import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest"; import UserUtils from "../utils/UserUtils"; import { AccessibilityAnnouncer } from "../design/shared"; import Dispatcher from "../Dispatcher"; import ClearAllIncomingRequestsConfirmationModal from "../modules/people/ClearAllIncomingRequestsConfirmationModal"; import SafetyToastsActionCreators_native from "../modules/safety_common/SafetyToastsActionCreators.native"; let c5831_10, c5831_12; const handleRelationshipAddError = function handleRelationshipAddError(a0, a1, discordTag) { let body2; const { status, body } = a0; let r8 = body && body.code; L19: { if (status === 429) { if (a1 === c5831_10.SHOW_ALWAYS) { const r130 = { title: intl.string(t["3D5eox"]), body: intl.string(t.TuJriJ), confirmText: intl.string(t.DppXIx) }; closeContextMenu(); AlertActionCreators.show(r130); } } else { if (status === 403 && r8 === AbortCodes.EMAIL_VERIFICATION_REQUIRED) { const r87 = { title: intl.string(t.Gqf33E), body: intl.string(t.GHOBdx), confirmText: intl.string(t.HbTSE6), onConfirm: () => { openClaimAccountModal(); } }; closeContextMenu(); AlertActionCreators.show(r87); break L19; } if (r8 === AbortCodes.USER_QUARANTINED) { closeContextMenu(); openQuarantineModeInfoModal_native(); } else if (!isLimitedAccessErrorCode(status, r8) && r8 !== AbortCodes.RELATIONSHIP_INVALID_NO_CONFIRMATION && a1 === c5831_10.SHOW_ALWAYS) { if (discordTag != null) { if (!r8) { r8 = 0; } body2 = humanizeAbortCode(r8, discordTag); } else { body2 = intl.string(t.paDJBM); } const r45 = { title: intl.string(t["6moJ8s"]), body: body2, confirmText: intl.string(t.BddRzS) }; closeContextMenu(); AlertActionCreators.show(r45); } } } throw a0; }; c5831_10 = { SHOW_ALWAYS: 0, 0: "SHOW_ALWAYS", SHOW_ONLY_IF_ACTION_NEEDED: 1, 1: "SHOW_ONLY_IF_ACTION_NEEDED" }; c5831_12 = { sendRequest: ({ discordTag, context, captchaPayload, note, errorUxConfig = c5831_10.SHOW_ALWAYS }) => { const SHOW_ALWAYS = errorUxConfig; const [username, r13] = discordTag.split("#"); return HTTP.post({ url: Endpoints.USER_RELATIONSHIPS(), body: { username, discriminator: parseInt(r13), note, ...captchaPayload }, context, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).catch((error) => { handleRelationshipAddError(error, SHOW_ALWAYS, discordTag); throw new Error("unreachable"); }); }, addRelationship: function addRelationship(a0, c16874_0) { const { userId: userId2, context, type, fromFriendSuggestion, confirmStrangerRequest, captchaPayload } = a0; let r18 = arguments[2]; if (r18 === void 0) { r18 = c5831_10.SHOW_ALWAYS; } const SHOW_ALWAYS2 = r18; const user = UserStore.getUser(userId2); return HTTP.put({ url: Endpoints.USER_RELATIONSHIP(userId2), body: { type, from_friend_suggestion: fromFriendSuggestion, confirm_stranger_request: confirmStrangerRequest, ...captchaPayload }, context, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then(() => { if (c16874_0 != null) { c16874_0(); } }).catch((error) => { handleRelationshipAddError(error, SHOW_ALWAYS2, UserUtils.getUserTag(user)); throw new Error("unreachable"); }); }, acceptFriendRequest: (a0) => c5831_12.addRelationship(a0, function() { AccessibilityAnnouncer.announce(intl.string(t["3goNa5"])); }), cancelFriendRequest: (a0, a1) => c5831_12.removeRelationship(a0, a1, function() { AccessibilityAnnouncer.announce(intl.string(t.pLUaxR)); }), removeFriend: (a0, a1) => { c5831_12.removeRelationship(a0, a1, function() { AccessibilityAnnouncer.announce(intl.string(t.vGSLa2)); }); }, blockUser: (a0, a1) => c5831_12.addRelationship({ userId: a0, context: a1, type: RelationshipTypes.BLOCKED }, function() { AccessibilityAnnouncer.announce(intl.string(t.mU0Vrp)); }), unblockUser: (a0, a1) => c5831_12.removeRelationship(a0, a1, function() { AccessibilityAnnouncer.announce(intl.string(t["9t1au7"])); }), removeRelationship: (a0, a1, c16875_0) => HTTP.del({ url: Endpoints.USER_RELATIONSHIP(a0), context: a1, oldFormErrors: true, rejectWithError: rejectWithMigratedError() }).then(() => { if (c16875_0 != null) { c16875_0(); } }).catch(() => { AccessibilityAnnouncer.announce(intl.string(t.n6Jo3E)); }), updateRelationship: (a0, a1) => HTTP.patch({ url: Endpoints.USER_RELATIONSHIP(a0), body: { nickname: a1 }, rejectWithError: rejectWithMigratedError() }), fetchRelationships: () => { HTTP.get({ url: Endpoints.USER_RELATIONSHIPS(), oldFormErrors: true, rejectWithError: true }).then((result) => Dispatcher.dispatch({ type: "LOAD_RELATIONSHIPS_SUCCESS", relationships: result.body }), () => Dispatcher.dispatch({ type: "LOAD_RELATIONSHIPS_FAILURE" })); }, confirmClearPendingRelationships: (a0) => { ClearAllIncomingRequestsConfirmationModal(a0); }, clearPendingRelationships: () => HTTP.del({ url: Endpoints.USER_RELATIONSHIPS(), query: { relationship_type: RelationshipTypes.PENDING_INCOMING }, rejectWithError: rejectWithMigratedError() }).then(() => { Dispatcher.dispatch({ type: "RELATIONSHIP_PENDING_INCOMING_REMOVED" }); }).catch(() => { AccessibilityAnnouncer.announce(intl.string(t.n6Jo3E)); }), clearPendingSpamAndIgnored: () => HTTP.del({ url: Endpoints.USER_RELATIONSHIPS(), query: { relationship_type: RelationshipTypes.PENDING_INCOMING }, body: { filters: [ClearFriendRequestFilters.SPAM, ClearFriendRequestFilters.IGNORED] }, rejectWithError: rejectWithMigratedError() }).then(() => { Dispatcher.dispatch({ type: "RELATIONSHIP_PENDING_INCOMING_REMOVED" }); }).catch(() => { AccessibilityAnnouncer.announce(intl.string(t.n6Jo3E)); }), ignoreUser: (a0, a1, c16876_1) => { const userId = a0; return HTTP.put({ url: Endpoints.IGNORE_USER(a0), context: { location: a1 }, rejectWithError: rejectWithMigratedError() }).then(() => { SafetyToastsActionCreators_native.showIgnoreSuccessToast(userId, c16876_1); AccessibilityAnnouncer.announce(intl.string(t.Us93Ca)); Dispatcher.dispatch({ type: "RELATIONSHIP_IGNORE_USER_SUCCESS", userId, timestamp: Date.now() }); }).catch(() => { SafetyToastsActionCreators_native.showFailedToast(); AccessibilityAnnouncer.announce(intl.string(t.n6Jo3E)); }); }, unignoreUser: (a0, a1, c16877_1) => { return HTTP.del({ url: Endpoints.IGNORE_USER(a0), context: { location: a1 }, rejectWithError: rejectWithMigratedError() }).then(() => { SafetyToastsActionCreators_native.showUnignoreSuccessToast(a0, c16877_1); AccessibilityAnnouncer.announce(intl.string(t.QlH5w6)); }).catch(() => { SafetyToastsActionCreators_native.showFailedToast(); AccessibilityAnnouncer.announce(intl.string(t.n6Jo3E)); }); } }; export default c5831_12; export { c5831_10 as RelationshipErrorUXConfig };