Files
WT-Offline/apps/server/src/items/item-expiry.ts
T

14 lines
617 B
TypeScript

/**
* Removing classic items whose time is up (items/<uid>/expiredTimeH), together with their place in the active lists. Run whenever a profile is handed out
* or changed, so the client never gets an expired item.
*/
import type { BlkBlock } from '@wto/blk';
import { ownedItems, removeItem } from '../profile/profile-items.ts';
import type { ServerTime } from '../profile/server-time.ts';
export function removeExpiredItems(profile: BlkBlock, now: ServerTime): void {
for (const item of ownedItems(profile)) {
if (item.expiresAt !== undefined && item.expiresAt <= now) removeItem(profile, item.uid);
}
}