rubberguppe/pub/object.js

18 lines
409 B
JavaScript
Raw Normal View History

'use strict'
const store = require('../store')
2019-09-22 05:20:37 +00:00
const federation = require('./federation')
module.exports = {
2019-09-22 05:20:37 +00:00
resolveObject
}
// find object in local DB or fetch from origin server
async function resolveObject (id, db) {
2019-09-22 05:20:37 +00:00
let object = await store.object.get(id, db)
if (object) {
return object
2019-09-22 05:20:37 +00:00
}
object = await federation.requestObject(id)
await store.object.save(object, db)
return object
}