()
| 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(); |
no test coverage detected