Skip to content

Commit

Permalink
Merge pull request infinitybase#345 from infinitybase/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
guimroque authored Dec 20, 2024
2 parents 8bf1756 + 379c414 commit 01f1a27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/api/src/modules/dApps/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export class DappController {

async currentAccount({ params, headers }: IDappRequest) {
try {
const dappCache = await RedisReadClient.get(`${PREFIX}${params.sessionId}`);
const dapp = dappCache ? JSON.parse(dappCache) : null;
if(dapp) {
return successful(
dapp.currentVault.predicateAddress,
Responses.Ok,
);
}
const account = await this._dappService.findBySessionID(
params.sessionId,
headers.origin ?? headers.Origin,
Expand Down Expand Up @@ -254,7 +262,7 @@ export class DappController {
const _dapp = await this._dappService
.findBySessionID(params.sessionId, headers.origin || headers.Origin)
.then((data: DApp) => {
return !!data;
return data;
});

if(!_dapp) {
Expand All @@ -263,9 +271,9 @@ export class DappController {
await RedisWriteClient.set(`${PREFIX}${params.sessionId}`, JSON.stringify(_dapp));
return successful(true, Responses.Ok);
}

return successful(
!!dapp,
true,
Responses.Ok,
);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/utils/redis/RedisWriteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class RedisWriteClient {
static async set(key: string, value: string | number) {
try {
await RedisWriteClient.client.set(key, value, {
EX: 60 * 40, // 40 minutes
EX: 60 * 40, // 5 min
});
} catch (e) {
console.error('[CACHE_SET_ERROR]', e, key, value);
Expand Down

0 comments on commit 01f1a27

Please sign in to comment.