MCPcopy Index your code
hub / github.com/MALSync/MALSync / databaseRequest

Method databaseRequest

src/_provider/Search/searchClass.ts:487–552  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

485 }
486
487 public async databaseRequest() {
488 const logger = this.logger.m('DB Request');
489 if (this.page && this.page.database && this.syncPage && this.state) {
490 if (this.state.cache) return;
491 if (this.state.provider === 'user' && !this.changed) return;
492 if (this.state.provider === 'firebase') return;
493 if (this.state.provider === 'local') return;
494
495 let kissurl;
496 if (!kissurl) {
497 if (this.page.isSyncPage(this.syncPage.url)) {
498 kissurl = this.page.sync.getOverviewUrl(this.syncPage.url);
499 if (this.page.database === 'Crunchyroll') {
500 kissurl = `${this.syncPage.url}`;
501 }
502 } else {
503 if (this.page.database === 'Crunchyroll') {
504 logger.log('CR block');
505 return;
506 }
507 kissurl = this.syncPage.url;
508 }
509 }
510 const param: {
511 pageUrl: string;
512 malUrl: string;
513 correction: boolean;
514 page: string;
515 } = {
516 pageUrl: kissurl,
517 malUrl: this.state.url,
518 correction: false,
519 page: this.page.database,
520 };
521 if (this.state.provider === 'user') {
522 if (
523 !(await utils.flashConfirm(
524 api.storage.lang('correction_DBRequest'),
525 'dbrequest',
526 () => undefined,
527 () => undefined,
528 true,
529 ))
530 )
531 return;
532 param.correction = true;
533 }
534
535 const url = 'https://api.malsync.moe/corrections';
536 api.request
537 .xhr('POST', {
538 url,
539 data: JSON.stringify(param),
540 headers: { 'Content-Type': 'application/json' },
541 })
542 .then(response => {
543 try {
544 const res = JSON.parse(response.responseText);

Callers 1

setCacheMethod · 0.95

Calls 3

langMethod · 0.80
xhrMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected