mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-03-21 17:44:49 -05:00
Mii uploads: use config for bucket name
This commit is contained in:
parent
04d206e3ed
commit
6d821d6af5
|
|
@ -10,6 +10,7 @@ PN_ACT_CONFIG_EMAIL_SES_REGION=region
|
|||
PN_ACT_CONFIG_EMAIL_SES_ACCESS_KEY=ACCESS_KEY
|
||||
PN_ACT_CONFIG_EMAIL_SES_SECRET_KEY=ACCESS_SECRET
|
||||
PN_ACT_CONFIG_EMAIL_FROM=Company Name <user@company.net>
|
||||
PN_ACT_CONFIG_S3_BUCKET=BUCKET_NAME
|
||||
PN_ACT_CONFIG_S3_ENDPOINT=nyc3.digitaloceanspaces.com
|
||||
PN_ACT_CONFIG_S3_ACCESS_KEY=ACCESS_KEY
|
||||
PN_ACT_CONFIG_S3_ACCESS_SECRET=ACCESS_SECRET
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ export const config: Config = {
|
|||
from: process.env.PN_ACT_CONFIG_EMAIL_FROM || ''
|
||||
},
|
||||
s3: {
|
||||
bucket: process.env.PN_ACT_CONFIG_S3_BUCKET || '',
|
||||
endpoint: process.env.PN_ACT_CONFIG_S3_ENDPOINT || '',
|
||||
key: process.env.PN_ACT_CONFIG_S3_ACCESS_KEY || '',
|
||||
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || '',
|
||||
|
|
@ -182,6 +183,11 @@ if (!config.hcaptcha.secret) {
|
|||
disabledFeatures.captcha = true;
|
||||
}
|
||||
|
||||
if (!config.s3.bucket) {
|
||||
LOG_WARN('Failed to find S3 bucket config. Disabling feature. To enable feature set the PN_ACT_CONFIG_S3_BUCKET environment variable');
|
||||
disabledFeatures.s3 = true;
|
||||
}
|
||||
|
||||
if (!config.s3.endpoint) {
|
||||
LOG_WARN('Failed to find S3 endpoint config. Disabling feature. To enable feature set the PN_ACT_CONFIG_S3_ENDPOINT environment variable');
|
||||
disabledFeatures.s3 = true;
|
||||
|
|
|
|||
|
|
@ -198,8 +198,8 @@ PNIDSchema.method('generateMiiImages', async function generateMiiImages(): Promi
|
|||
|
||||
const userMiiKey = `mii/${this.pid}`;
|
||||
|
||||
await uploadCDNAsset('pn-cdn', `${userMiiKey}/standard.tga`, tga, 'public-read');
|
||||
await uploadCDNAsset('pn-cdn', `${userMiiKey}/normal_face.png`, miiStudioNormalFaceImageData, 'public-read');
|
||||
await uploadCDNAsset(`${config.s3.bucket}`, `${userMiiKey}/standard.tga`, tga, 'public-read');
|
||||
await uploadCDNAsset(`${config.s3.bucket}`, `${userMiiKey}/normal_face.png`, miiStudioNormalFaceImageData, 'public-read');
|
||||
|
||||
const expressions = ['frustrated', 'smile_open_mouth', 'wink_left', 'sorrow', 'surprise_open_mouth'];
|
||||
for (const expression of expressions) {
|
||||
|
|
@ -210,7 +210,7 @@ PNIDSchema.method('generateMiiImages', async function generateMiiImages(): Promi
|
|||
instanceCount: 1,
|
||||
});
|
||||
const miiStudioExpressionImageData = await got(miiStudioExpressionUrl).buffer();
|
||||
await uploadCDNAsset('pn-cdn', `${userMiiKey}/${expression}.png`, miiStudioExpressionImageData, 'public-read');
|
||||
await uploadCDNAsset(`${config.s3.bucket}`, `${userMiiKey}/${expression}.png`, miiStudioExpressionImageData, 'public-read');
|
||||
}
|
||||
|
||||
const miiStudioBodyUrl = mii.studioUrl({
|
||||
|
|
@ -219,7 +219,7 @@ PNIDSchema.method('generateMiiImages', async function generateMiiImages(): Promi
|
|||
instanceCount: 1,
|
||||
});
|
||||
const miiStudioBodyImageData = await got(miiStudioBodyUrl).buffer();
|
||||
await uploadCDNAsset('pn-cdn', `${userMiiKey}/body.png`, miiStudioBodyImageData, 'public-read');
|
||||
await uploadCDNAsset(`${config.s3.bucket}`, `${userMiiKey}/body.png`, miiStudioBodyImageData, 'public-read');
|
||||
});
|
||||
|
||||
PNIDSchema.method('scrub', async function scrub() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export interface Config {
|
|||
from: string;
|
||||
};
|
||||
s3: {
|
||||
bucket: string;
|
||||
endpoint: string;
|
||||
key: string;
|
||||
secret: string;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user