MCPcopy Create free account
hub / github.com/NobyDa/Script / ChangeBody

Function ChangeBody

TestFlight/TestFlightAccount.js:141–180  ·  view source on GitHub ↗
(resp)

Source from the content-addressed store, hash-verified

139}
140
141function ChangeBody(resp) {
142 if (req.url.endsWith('/apps')) {
143 resp = resp.reduce((t, d) => {
144 d.body = JSON.parse(d.status == 200 && d.body || '{}');
145 $.log(`Account "${d.account}" app list: ${$.stringify((d.body.data || []).map(i => i.name))}`);
146 d.body.data = (d.body.data || []).map(i => {
147 if ($.ForceIOSlist) {
148 i.platforms = i.platforms.map(j => {
149 if (j.name == 'osx') {
150 $.log(`Account "${d.account}" app [${i.name}] force mac compatible`);
151 j.build.compatible = true;
152 j.build.platformCompatible = true;
153 j.build.osCompatible = true;
154 j.build.hardwareCompatible = true;
155 }
156 return j
157 })
158 }
159 i.aid = d.account;
160 const only = !list[d.account].only || list[d.account].only.includes(String(i.appAdamId));
161 return only && t.body.data[req.url.includes(d.account) ? 'unshift' : 'push'](i), i;
162 });
163 if (req.url.includes(d.account)) {
164 [t.status, t.headers] = [d.status, d.headers];
165 }
166 return t
167 }, { body: { data: [], error: null } });
168 resp.body.data = resp.body.data.filter(r => !r.previouslyTested && !obj.has(r.appAdamId) && obj.set(r.appAdamId, 1));
169 $.write(resp.body.data.reduce((l, v) => (l[v.appAdamId] = v.aid, l), {}), 'AppList');
170 $.log(`Final app: ${$.stringify(resp.body.data.map(i => i.name))}`);
171 resp.body = JSON.stringify(resp.body);
172 }
173 if (/\/apps\/\d+\/builds\/\d+$/.test(req.url) && resp.status == 200 && resp.body) { //beta app page
174 const share = ShareAccount(req.url.split(/\/apps\/(\d+)/)[1]);
175 resp.body = JSON.parse(resp.body);
176 resp.body.data.builds.map(e => e.description = `${e.description || '-'}${share}`);
177 resp.body = JSON.stringify(resp.body);
178 }
179 return resp;
180}
181
182function QueryRequest(o) {
183 const option = ChangeHeaders(o);

Callers 1

Calls 4

ShareAccountFunction · 0.85
logMethod · 0.45
stringifyMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected