Migrate to the official F-Droid API (#5416)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -65,7 +65,7 @@ module.exports = class FDroid extends BaseJsonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetch({ appId }) {
|
async fetch({ appId }) {
|
||||||
const url = `https://gitlab.com/kitsunyan/fdroidapi/raw/master/applications/${appId}`
|
const url = `https://f-droid.org/api/v1/packages/${appId}`
|
||||||
return this._requestJson({
|
return this._requestJson({
|
||||||
schema,
|
schema,
|
||||||
url,
|
url,
|
||||||
@@ -76,9 +76,8 @@ module.exports = class FDroid extends BaseJsonService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle({ appId }, { include_prereleases: prereleases }) {
|
transform({ json, suggested }) {
|
||||||
const json = await this.fetch({ appId })
|
const svc = suggested && json.suggestedVersionCode
|
||||||
const svc = prereleases === undefined && json.suggestedVersionCode
|
|
||||||
const packages = (json.packages || []).filter(
|
const packages = (json.packages || []).filter(
|
||||||
({ versionCode }) => !svc || versionCode <= svc
|
({ versionCode }) => !svc || versionCode <= svc
|
||||||
)
|
)
|
||||||
@@ -88,6 +87,13 @@ module.exports = class FDroid extends BaseJsonService {
|
|||||||
const version = packages.reduce((a, b) =>
|
const version = packages.reduce((a, b) =>
|
||||||
a.versionCode > b.versionCode ? a : b
|
a.versionCode > b.versionCode ? a : b
|
||||||
).versionName
|
).versionName
|
||||||
|
return { version }
|
||||||
|
}
|
||||||
|
|
||||||
|
async handle({ appId }, { include_prereleases }) {
|
||||||
|
const json = await this.fetch({ appId })
|
||||||
|
const suggested = include_prereleases === undefined
|
||||||
|
const { version } = this.transform({ json, suggested })
|
||||||
return this.constructor.render({ version })
|
return this.constructor.render({ version })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ const testJson = `
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const base = 'https://gitlab.com/kitsunyan/fdroidapi'
|
const base = 'https://f-droid.org/api/v1'
|
||||||
const path = `/raw/master/applications/${testPkg}`
|
const path = `/packages/${testPkg}`
|
||||||
|
|
||||||
t.create('Package is found')
|
t.create('Package is found')
|
||||||
.get(`/v/${testPkg}.json`)
|
.get(`/v/${testPkg}.json`)
|
||||||
|
|||||||
Reference in New Issue
Block a user