Support consume api

This commit is contained in:
Johannes Zellner
2023-03-09 18:59:04 +01:00
parent 5fcadcce9c
commit 47e35d0b06
+6 -4
View File
@@ -55,7 +55,7 @@ class CloudronAdapter {
async upsert(id, payload, expiresIn) {
debug(`[${this.name}] upsert id:${id} expiresIn:${expiresIn}`, payload);
this.store[id] = payload;
this.store[id] = { id, expiresIn, payload, consumed: false };
fs.writeFileSync(this.fileStorePath, JSON.stringify(this.store), 'utf8');
}
@@ -74,7 +74,7 @@ class CloudronAdapter {
if (!this.store[id]) return false;
return this.store[id];
return this.store[id].payload;
}
/**
@@ -106,7 +106,7 @@ class CloudronAdapter {
debug(`[${this.name}] findByUid uid:${uid}`);
for (let d in this.store) {
if (this.store[d].uid === uid) return this.store[d];
if (this.store[d].uid === uid) return this.store[d].payload;
}
return false;
@@ -124,7 +124,9 @@ class CloudronAdapter {
*
*/
async consume(id) {
debug(`[${this.name}] FIXME consume id:${id}`);
debug(`[${this.name}] consume id:${id}`);
if (this.store[id]) this.store[id].consumed = true;
}
/**