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

Method init

src/utils/customDomains.ts:46–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44 }
45
46 async init() {
47 return api.request.xhr('GET', 'https://api.malsync.moe/general/permissions').then(response => {
48 const permissions: { [index: string]: { [index: string]: string[] } } = JSON.parse(
49 response.responseText,
50 );
51 // Versions that are gte than the current version
52 const versions = Object.keys(permissions)
53 .filter(key => key !== 'ttl')
54 .filter(key => greaterOrEqualCurrentVersion(key));
55
56 const missingPermissions = versions.reduce((acc, version) => {
57 for (const key in permissions[version]) {
58 // check if key exists in options
59 if (!this.options.some(option => option.key === key)) {
60 continue;
61 }
62
63 if (acc[key]) {
64 acc[key] = acc[key].concat(permissions[version][key]);
65 } else {
66 acc[key] = permissions[version][key];
67 }
68 }
69 return acc;
70 }, {});
71
72 this.missingPermissions = missingPermissions;
73 });
74 }
75
76 getMissingPermissions(currentCustomDomains: domainType[]) {
77 const formated = this.getFormatedPermissions();

Callers 1

hasMissingPermissionsFunction · 0.95

Calls 3

xhrMethod · 0.80
keysMethod · 0.80

Tested by

no test coverage detected