Last active
June 21, 2021 22:06
-
-
Save gnprice/f5f497e730f1599081c4b4e4728b158f to your computer and use it in GitHub Desktop.
Generated notifs code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable */ | |
| !(function(r) { | |
| (r.__r = o), | |
| (r.__d = function(r, i, n) { | |
| if (e[i] != null) { | |
| return; | |
| } | |
| const o = { | |
| dependencyMap: n, | |
| factory: r, | |
| hasError: !1, | |
| importedAll: t, | |
| importedDefault: t, | |
| isInitialized: !1, | |
| publicModule: { exports: {} }, | |
| }; | |
| e[i] = o; | |
| }), | |
| (r.__c = n), | |
| (r.__registerSegment = function(r, e) { | |
| s[r] = e; | |
| }); | |
| var e = n(); | |
| var t = {}; | |
| const i = {}.hasOwnProperty; | |
| function n() { | |
| return (e = Object.create(null)); | |
| } | |
| function o(r) { | |
| const t = r; | |
| const i = e[t]; | |
| return i && i.isInitialized ? i.publicModule.exports : d(t, i); | |
| } | |
| function l(r) { | |
| const i = r; | |
| if (e[i] && e[i].importedDefault !== t) { | |
| return e[i].importedDefault; | |
| } | |
| const n = o(i); | |
| const l = n && n.__esModule ? n.default : n; | |
| return (e[i].importedDefault = l); | |
| } | |
| function u(r) { | |
| const n = r; | |
| if (e[n] && e[n].importedAll !== t) { | |
| return e[n].importedAll; | |
| } | |
| let l; | |
| const u = o(n); | |
| if (u && u.__esModule) { | |
| l = u; | |
| } else { | |
| if (((l = {}), u)) { | |
| for (const a in u) { | |
| i.call(u, a) && (l[a] = u[a]); | |
| } | |
| } | |
| l.default = u; | |
| } | |
| return (e[n].importedAll = l); | |
| } | |
| (o.importDefault = l), (o.importAll = u); | |
| let a = !1; | |
| function d(e, t) { | |
| if (!a && r.ErrorUtils) { | |
| let i; | |
| a = !0; | |
| try { | |
| i = v(e, t); | |
| } catch (e) { | |
| r.ErrorUtils.reportFatalError(e); | |
| } | |
| return (a = !1), i; | |
| } | |
| return v(e, t); | |
| } | |
| const c = 16; | |
| const f = 65535; | |
| function p(r) { | |
| return { segmentId: r >>> c, localId: r & f }; | |
| } | |
| (o.unpackModuleId = p), | |
| (o.packModuleId = function(r) { | |
| return (r.segmentId << c) + r.localId; | |
| }); | |
| var s = []; | |
| function v(t, i) { | |
| if (!i && s.length > 0) { | |
| const n = p(t); | |
| const a = n.segmentId; | |
| const d = n.localId; | |
| const c = s[a]; | |
| c != null && (c(d), (i = e[t])); | |
| } | |
| const f = r.nativeRequire; | |
| if (!i && f) { | |
| const v = p(t); | |
| const h = v.segmentId; | |
| f(v.localId, h), (i = e[t]); | |
| } | |
| if (!i) { | |
| throw Error(`Requiring unknown module "${t}".`); | |
| } | |
| if (i.hasError) { | |
| throw m(t, i.error); | |
| } | |
| i.isInitialized = !0; | |
| const I = i; | |
| const g = I.factory; | |
| const y = I.dependencyMap; | |
| try { | |
| const _ = i.publicModule; | |
| return ( | |
| (_.id = t), | |
| g(r, o, l, u, _, _.exports, y), | |
| (i.factory = void 0), | |
| (i.dependencyMap = void 0), | |
| _.exports | |
| ); | |
| } catch (r) { | |
| throw ((i.hasError = !0), | |
| (i.error = r), | |
| (i.isInitialized = !1), | |
| (i.publicModule.exports = void 0), | |
| r); | |
| } | |
| } | |
| function m(r, e) { | |
| return Error(`Requiring module "${r}", which threw an exception: ${e}`); | |
| } | |
| })( | |
| typeof globalThis !== 'undefined' | |
| ? globalThis | |
| : typeof global !== 'undefined' | |
| ? global | |
| : typeof window !== 'undefined' | |
| ? window | |
| : this, | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable */ | |
| __d( | |
| function(g, r, i, a, m, e, d) { | |
| var t = r(d[0]); | |
| Object.defineProperty(e, '__esModule', { value: !0 }), | |
| (e.tryStopNotifications = e.initNotifications = e.sendAllPushToken = e.narrowToNotification = e.unackPushToken = e.gotPushToken = void 0); | |
| var n = t(r(d[1])), | |
| u = r(d[2]), | |
| o = (function(t, n) { | |
| if (!n && t && t.__esModule) return t; | |
| if (null === t || ('object' != typeof t && 'function' != typeof t)) return { default: t }; | |
| var u = h(n); | |
| if (u && u.has(t)) return u.get(t); | |
| var o = {}, | |
| c = Object.defineProperty && Object.getOwnPropertyDescriptor; | |
| for (var s in t) | |
| if ('default' !== s && Object.prototype.hasOwnProperty.call(t, s)) { | |
| var f = c ? Object.getOwnPropertyDescriptor(t, s) : null; | |
| f && (f.get || f.set) ? Object.defineProperty(o, s, f) : (o[s] = t[s]); | |
| } | |
| (o.default = t), u && u.set(t, o); | |
| return o; | |
| })(r(d[3])), | |
| c = r(d[4]), | |
| s = r(d[5]), | |
| f = r(d[6]), | |
| l = r(d[7]), | |
| p = r(d[8]), | |
| k = r(d[9]), | |
| y = r(d[10]), | |
| v = r(d[11]), | |
| P = r(d[12]); | |
| function h(t) { | |
| if ('function' != typeof WeakMap) return null; | |
| var n = new WeakMap(), | |
| u = new WeakMap(); | |
| return (h = function(t) { | |
| return t ? u : n; | |
| })(t); | |
| } | |
| e.gotPushToken = function(t) { | |
| return { type: l.GOT_PUSH_TOKEN, pushToken: t }; | |
| }; | |
| e.unackPushToken = function(t) { | |
| return { type: l.UNACK_PUSH_TOKEN, identity: t }; | |
| }; | |
| var T = function(t, n) { | |
| return { type: l.ACK_PUSH_TOKEN, identity: n, pushToken: t }; | |
| }; | |
| e.narrowToNotification = function(t) { | |
| return function(n, u) { | |
| if (t) { | |
| var o = u(), | |
| s = (0, c.getAccountFromNotificationData)(t, (0, P.getIdentities)(o)); | |
| if (null !== s && s > 0) n((0, v.accountSwitch)(s)); | |
| else { | |
| var f = (0, c.getNarrowFromNotificationData)( | |
| t, | |
| (0, k.getAllUsersByEmail)(o), | |
| (0, k.getOwnUserId)(o), | |
| ); | |
| f && n((0, y.doNarrow)(f)); | |
| } | |
| } | |
| }; | |
| }; | |
| var w = function(t, c, s) { | |
| var f; | |
| return n.default.async( | |
| function(l) { | |
| for (;;) | |
| switch ((l.prev = l.next)) { | |
| case 0: | |
| if (c && '' !== c.apiKey) { | |
| l.next = 2; | |
| break; | |
| } | |
| return l.abrupt('return'); | |
| case 2: | |
| if (c.ackedPushToken !== s) { | |
| l.next = 4; | |
| break; | |
| } | |
| return l.abrupt('return'); | |
| case 4: | |
| return ( | |
| (f = (0, p.authOfAccount)(c)), | |
| (l.next = 7), | |
| n.default.awrap(o.savePushToken(f, u.Platform.OS, s)) | |
| ); | |
| case 7: | |
| t(T(s, (0, p.identityOfAccount)(c))); | |
| case 8: | |
| case 'end': | |
| return l.stop(); | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }; | |
| e.sendAllPushToken = function() { | |
| return function(t, u) { | |
| var o, c, s; | |
| return n.default.async( | |
| function(l) { | |
| for (;;) | |
| switch ((l.prev = l.next)) { | |
| case 0: | |
| if (((o = (0, f.getSession)(u())), null !== (c = o.pushToken))) { | |
| l.next = 3; | |
| break; | |
| } | |
| return l.abrupt('return'); | |
| case 3: | |
| return ( | |
| (s = (0, f.getAccounts)(u())), | |
| (l.next = 6), | |
| n.default.awrap( | |
| Promise.all( | |
| s.map(function(n) { | |
| return w(t, n, c); | |
| }), | |
| ), | |
| ) | |
| ); | |
| case 6: | |
| case 'end': | |
| return l.stop(); | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }; | |
| }; | |
| e.initNotifications = function() { | |
| return function(t, u) { | |
| var o, l, p; | |
| return n.default.async( | |
| function(k) { | |
| for (;;) | |
| switch ((k.prev = k.next)) { | |
| case 0: | |
| if (((o = (0, f.getSession)(u())), null !== (l = o.pushToken))) { | |
| k.next = 4; | |
| break; | |
| } | |
| return (0, c.getNotificationToken)(), k.abrupt('return'); | |
| case 4: | |
| return ( | |
| (p = (0, s.getActiveAccount)(u())), (k.next = 7), n.default.awrap(w(t, p, l)) | |
| ); | |
| case 7: | |
| case 'end': | |
| return k.stop(); | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }; | |
| }; | |
| e.tryStopNotifications = function() { | |
| return function(t, u) { | |
| var o, f, l; | |
| return n.default.async( | |
| function(n) { | |
| for (;;) | |
| switch ((n.prev = n.next)) { | |
| case 0: | |
| (o = (0, s.getAuth)(u())), | |
| (f = (0, s.getActiveAccount)(u())), | |
| (l = f.ackedPushToken), | |
| (0, c.tryStopNotifications)(o, l, t); | |
| case 3: | |
| case 'end': | |
| return n.stop(); | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }; | |
| }; | |
| }, | |
| 1944, | |
| [1, 101, 2, 1493, 1849, 704, 707, 1410, 708, 720, 1945, 1930, 705], | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable */ | |
| __d( | |
| (g, r, i, a, m, e, d) => { | |
| const t = r(d[0]); | |
| Object.defineProperty(e, '__esModule', { value: !0 }), | |
| (e.tryStopNotifications = e.getNotificationToken = e.NotificationListener = e.handleInitialNotification = e.getNarrowFromNotificationData = e.getAccountFromNotificationData = void 0); | |
| const n = t(r(d[1])); | |
| const o = t(r(d[2])); | |
| const u = t(r(d[3])); | |
| const s = r(d[4]); | |
| const l = t(r(d[5])); | |
| const c = r(d[6]); | |
| const f = b(r(d[7])); | |
| const p = b(r(d[8])); | |
| const h = r(d[9]); | |
| const v = r(d[10]); | |
| const k = r(d[11]); | |
| const N = r(d[12]); | |
| const w = r(d[13]); | |
| const y = r(d[14]); | |
| function O(t) { | |
| if (typeof WeakMap !== 'function') { | |
| return null; | |
| } | |
| const n = new WeakMap(); | |
| const o = new WeakMap(); | |
| return (O = function(t) { | |
| return t ? o : n; | |
| })(t); | |
| } | |
| function b(t, n) { | |
| if (!n && t && t.__esModule) { | |
| return t; | |
| } | |
| if (t === null || (typeof t !== 'object' && typeof t !== 'function')) { | |
| return { default: t }; | |
| } | |
| const o = O(n); | |
| if (o && o.has(t)) { | |
| return o.get(t); | |
| } | |
| const u = {}; | |
| const s = Object.defineProperty && Object.getOwnPropertyDescriptor; | |
| for (const l in t) { | |
| if (l !== 'default' && Object.prototype.hasOwnProperty.call(t, l)) { | |
| const c = s ? Object.getOwnPropertyDescriptor(t, l) : null; | |
| c && (c.get || c.set) ? Object.defineProperty(u, l, c) : (u[l] = t[l]); | |
| } | |
| } | |
| return (u.default = t), o && o.set(t, u), u; | |
| } | |
| e.getAccountFromNotificationData = function(t, n) { | |
| const o = t.realm_uri; | |
| if (o == null) { | |
| return p.warn('notification missing field: realm_uri'), null; | |
| } | |
| const u = (0, N.tryParseUrl)(o); | |
| if (void 0 === u) { | |
| return p.warn('notification realm_uri invalid as URL', { realm_uri: o }), null; | |
| } | |
| const s = []; | |
| if ( | |
| (n.forEach((t, n) => { | |
| t.realm.href === u.href && s.push(n); | |
| }), | |
| s.length === 0) | |
| ) { | |
| const l = n.map(t => t.realm.href); | |
| return ( | |
| p.warn('notification realm_uri not found in accounts', { | |
| realm_uri: o, | |
| parsed_url: u, | |
| known_urls: l, | |
| }), | |
| null | |
| ); | |
| } | |
| return s.length > 1 | |
| ? (p.warn('notification realm_uri ambiguous; multiple matches found', { | |
| realm_uri: o, | |
| parsed_url: u, | |
| match_count: s.length, | |
| }), | |
| null) | |
| : s[0]; | |
| }; | |
| e.getNarrowFromNotificationData = function(t, n, o) { | |
| if (!t.recipient_type) { | |
| return null; | |
| } | |
| if (t.recipient_type === 'stream') { | |
| return (0, c.topicNarrow)(t.stream, t.topic); | |
| } | |
| if (void 0 === t.pm_users) { | |
| let u; | |
| const s = n.get(t.sender_email); | |
| return (u = s && (0, c.pm1to1NarrowFromUser)(s)) != null ? u : null; | |
| } | |
| const l = t.pm_users.split(',').map(t => (0, y.makeUserId)(parseInt(t, 10))); | |
| return (0, c.pmNarrowFromRecipients)((0, w.pmKeyRecipientsFromIds)(l, o)); | |
| }; | |
| const P = function() { | |
| let t; | |
| let n; | |
| return u.default.async( | |
| o => { | |
| for (;;) { | |
| switch ((o.prev = o.next)) { | |
| case 0: | |
| if (s.Platform.OS !== 'android') { | |
| o.next = 3; | |
| break; | |
| } | |
| return ( | |
| (t = s.NativeModules.Notifications), | |
| o.abrupt('return', t.readInitialNotification()) | |
| ); | |
| case 3: | |
| return (o.next = 5), u.default.awrap(l.default.getInitialNotification()); | |
| case 5: | |
| if ((n = o.sent)) { | |
| o.next = 8; | |
| break; | |
| } | |
| return o.abrupt('return', null); | |
| case 8: | |
| return o.abrupt('return', (0, k.fromPushNotificationIOS)(n) || null); | |
| case 9: | |
| case 'end': | |
| return o.stop(); | |
| } | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }; | |
| e.handleInitialNotification = function(t) { | |
| let n; | |
| return u.default.async( | |
| o => { | |
| for (;;) { | |
| switch ((o.prev = o.next)) { | |
| case 0: | |
| return (o.next = 2), u.default.awrap(P()); | |
| case 2: | |
| (n = o.sent), t((0, h.narrowToNotification)(n)); | |
| case 4: | |
| case 'end': | |
| return o.stop(); | |
| } | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }; | |
| const _ = (function() { | |
| function t(o) { | |
| const s = this; | |
| (0, n.default)(this, t), | |
| (this.unsubs = []), | |
| (this.handleNotificationOpen = function(t) { | |
| s.dispatch((0, h.narrowToNotification)(t)); | |
| }), | |
| (this.handleDeviceToken = function(t) { | |
| let n; | |
| return u.default.async( | |
| o => { | |
| for (;;) { | |
| switch ((o.prev = o.next)) { | |
| case 0: | |
| if (t === null || typeof t === 'string') { | |
| o.next = 4; | |
| break; | |
| } | |
| return ( | |
| (n = t), | |
| p.error('Received invalid device token', { token: n }), | |
| o.abrupt('return') | |
| ); | |
| case 4: | |
| return ( | |
| s.dispatch((0, h.gotPushToken)(t)), | |
| (o.next = 7), | |
| u.default.awrap(s.dispatch((0, h.sendAllPushToken)())) | |
| ); | |
| case 7: | |
| case 'end': | |
| return o.stop(); | |
| } | |
| } | |
| }, | |
| null, | |
| null, | |
| null, | |
| Promise, | |
| ); | |
| }), | |
| (this.handleIOSRegistrationFailure = function(t) { | |
| p.warn(`Failed to register iOS push token: ${t.code}`, { raw_error: t }); | |
| }), | |
| (this.dispatch = o); | |
| } | |
| return ( | |
| (0, o.default)(t, [ | |
| { | |
| key: 'listenIOS', | |
| value(t, n) { | |
| l.default.addEventListener(t, n), | |
| this.unsubs.push(() => l.default.removeEventListener(t)); | |
| }, | |
| }, | |
| { | |
| key: 'listenAndroid', | |
| value(t, n) { | |
| const o = s.DeviceEventEmitter.addListener(t, n); | |
| this.unsubs.push(() => o.remove()); | |
| }, | |
| }, | |
| { | |
| key: 'unlistenAll', | |
| value() { | |
| for (; this.unsubs.length > 0; ) { | |
| this.unsubs.pop()(); | |
| } | |
| }, | |
| }, | |
| { | |
| key: 'start', | |
| value() { | |
| const t = this; | |
| return u.default.async( | |
| function(n) { | |
| for (;;) { | |
| switch ((n.prev = n.next)) { | |
| case 0: | |
| if ( | |
| (s.Platform.OS === 'android' | |
| ? (this.listenAndroid( | |
| 'notificationOpened', | |
| this.handleNotificationOpen, | |
| ), | |
| this.listenAndroid( | |
| 'remoteNotificationsRegistered', | |
| this.handleDeviceToken, | |
| )) | |
| : (this.listenIOS('notification', n => { | |
| const o = (0, k.fromPushNotificationIOS)(n); | |
| o && t.handleNotificationOpen(o); | |
| }), | |
| this.listenIOS('register', this.handleDeviceToken), | |
| this.listenIOS( | |
| 'registrationError', | |
| this.handleIOSRegistrationFailure, | |
| )), | |
| s.Platform.OS !== 'android') | |
| ) { | |
| n.next = 9; | |
| break; | |
| } | |
| return ( | |
| (n.t0 = this), | |
| (n.next = 5), | |
| u.default.awrap(s.NativeModules.Notifications.getToken()) | |
| ); | |
| case 5: | |
| (n.t1 = n.sent), n.t0.handleDeviceToken.call(n.t0, n.t1), (n.next = 9); | |
| break; | |
| case 9: | |
| case 'end': | |
| return n.stop(); | |
| } | |
| } | |
| }, | |
| null, | |
| this, | |
| null, | |
| Promise, | |
| ); | |
| }, | |
| }, | |
| { | |
| key: 'stop', | |
| value() { | |
| this.unlistenAll(); | |
| }, | |
| }, | |
| ]), | |
| t | |
| ); | |
| })(); | |
| e.NotificationListener = _; | |
| e.getNotificationToken = function() { | |
| s.Platform.OS === 'ios' && l.default.requestPermissions(); | |
| }; | |
| e.tryStopNotifications = function(t, n, o) { | |
| return u.default.async( | |
| l => { | |
| for (;;) { | |
| switch ((l.prev = l.next)) { | |
| case 0: | |
| if (n === null) { | |
| l.next = 10; | |
| break; | |
| } | |
| return ( | |
| o((0, h.unackPushToken)((0, v.identityOfAuth)(t))), | |
| (l.prev = 2), | |
| (l.next = 5), | |
| u.default.awrap(f.forgetPushToken(t, s.Platform.OS, n)) | |
| ); | |
| case 5: | |
| l.next = 10; | |
| break; | |
| case 7: | |
| (l.prev = 7), (l.t0 = l.catch(2)), p.warn(l.t0); | |
| case 10: | |
| case 'end': | |
| return l.stop(); | |
| } | |
| } | |
| }, | |
| null, | |
| null, | |
| [[2, 7]], | |
| Promise, | |
| ); | |
| }; | |
| }, | |
| 2410, | |
| [1, 24, 25, 101, 2, 2411, 716, 1493, 439, 1944, 708, 2412, 1499, 718, 717], | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment