rubberguppe/pub/object.js
2019-09-22 00:20:37 -05:00

17 lines
409 B
JavaScript

'use strict'
const store = require('../store')
const federation = require('./federation')
module.exports = {
resolveObject
}
// find object in local DB or fetch from origin server
async function resolveObject (id, db) {
let object = await store.object.get(id, db)
if (object) {
return object
}
object = await federation.requestObject(id)
await store.object.save(object, db)
return object
}