Changes (/shrug)
* Added middleware timer for performance debugging * Relationships and avatar database keys * CDN * Profiles are SelfAccounts in most cases, rather than Accounts * Simplified profile content management * Progression fixes * Relationships (favorites not yet implemented) * Relationship backend * Relationship and avatar routes
This commit is contained in:
46
src/data/profile/avatar.ts
Normal file
46
src/data/profile/avatar.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Redis } from "../../db.ts";
|
||||
import { ProfileContentManager } from "./base/profilemanagerbase.ts";
|
||||
|
||||
interface AvatarSettings {
|
||||
OutfitSelections: string,
|
||||
HairColor: string,
|
||||
SkinColor: string,
|
||||
FaceFeatures: string
|
||||
}
|
||||
|
||||
export class ProfileAvatarManager extends ProfileContentManager {
|
||||
|
||||
#rootKey = Redis.buildKey(
|
||||
Redis.KeyGroups.Profiles.Root,
|
||||
this.profileId.toString(),
|
||||
Redis.KeyGroups.Profiles.Avatar.Root
|
||||
);
|
||||
|
||||
async setAvatar(settings: AvatarSettings) {
|
||||
const keys = Redis.KeyGroups.Profiles.Avatar;
|
||||
await Promise.all([
|
||||
Redis.Database.set(Redis.buildKey(this.#rootKey, keys.Outfit), settings.OutfitSelections),
|
||||
Redis.Database.set(Redis.buildKey(this.#rootKey, keys.Hair), settings.HairColor),
|
||||
Redis.Database.set(Redis.buildKey(this.#rootKey, keys.Skin), settings.SkinColor),
|
||||
Redis.Database.set(Redis.buildKey(this.#rootKey, keys.Face), settings.FaceFeatures),
|
||||
]);
|
||||
}
|
||||
|
||||
async getAvatar() {
|
||||
const keys = Redis.KeyGroups.Profiles.Avatar;
|
||||
const [outfit, hair, skin, face] = await Promise.all([
|
||||
Redis.Database.get(Redis.buildKey(this.#rootKey, keys.Outfit)),
|
||||
Redis.Database.get(Redis.buildKey(this.#rootKey, keys.Hair)),
|
||||
Redis.Database.get(Redis.buildKey(this.#rootKey, keys.Skin)),
|
||||
Redis.Database.get(Redis.buildKey(this.#rootKey, keys.Face))
|
||||
]);
|
||||
|
||||
return {
|
||||
OutfitSelections: outfit ?? "",
|
||||
HairColor: hair ?? "",
|
||||
SkinColor: skin ?? "",
|
||||
FaceFeatures: face ?? ""
|
||||
} as AvatarSettings;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user