add ability to req temporary t3 thru eds
parent
8ce7f51f8d
commit
95468f3cf1
|
@ -15,6 +15,7 @@ configs/config.yaml
|
||||||
src/config.yaml
|
src/config.yaml
|
||||||
build/config.yaml
|
build/config.yaml
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
google.json
|
google.json
|
||||||
src/google.json
|
src/google.json
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
88
package.json
88
package.json
|
@ -10,58 +10,58 @@
|
||||||
"author": "Matthew R, AD, FSEN <matthew@staff.libraryofcode.org>",
|
"author": "Matthew R, AD, FSEN <matthew@staff.libraryofcode.org>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/ari-client": "^2.2.2",
|
"@types/ari-client": "^2.2.7",
|
||||||
"@types/auth0": "^2.33.3",
|
"@types/auth0": "^2.34.7",
|
||||||
"@types/bull": "^3.14.4",
|
"@types/bull": "^3.15.7",
|
||||||
"@types/cron": "^1.7.2",
|
"@types/cron": "^1.7.3",
|
||||||
"@types/express": "^4.17.6",
|
"@types/express": "^4.17.13",
|
||||||
"@types/helmet": "^0.0.47",
|
"@types/helmet": "^0.0.48",
|
||||||
"@types/jsonwebtoken": "^8.5.0",
|
"@types/jsonwebtoken": "^8.5.6",
|
||||||
"@types/mathjs": "^6.0.7",
|
"@types/mathjs": "^9.4.1",
|
||||||
"@types/mongoose": "^5.7.19",
|
"@types/mongoose": "^5.11.96",
|
||||||
"@types/node": "^14.14.25",
|
"@types/node": "^16.11.12",
|
||||||
"@types/nodemailer": "^6.4.0",
|
"@types/nodemailer": "^6.4.4",
|
||||||
"@types/puppeteer": "^5.4.3",
|
"@types/puppeteer": "^5.4.4",
|
||||||
"@types/signale": "^1.4.1",
|
"@types/signale": "^1.4.2",
|
||||||
"@types/uuid": "^7.0.3",
|
"@types/uuid": "^8.3.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.33.0",
|
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
||||||
"@typescript-eslint/parser": "^2.33.0",
|
"@typescript-eslint/parser": "^5.6.0",
|
||||||
"eslint": "^7.19.0",
|
"eslint": "^8.4.1",
|
||||||
"eslint-config-airbnb-base": "^14.1.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
"tslib": "^2.1.0",
|
"tslib": "^2.3.1",
|
||||||
"typescript": "^3.9.2"
|
"typescript": "^4.5.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@google-cloud/text-to-speech": "^3.1.2",
|
"@google-cloud/text-to-speech": "^3.4.0",
|
||||||
"ari-client": "^2.2.0",
|
"ari-client": "^2.2.0",
|
||||||
"asterisk-manager": "^0.1.16",
|
"asterisk-manager": "^0.2.0",
|
||||||
"auth0": "^2.35.0",
|
"auth0": "^2.37.0",
|
||||||
"awesome-phonenumber": "^2.45.0",
|
"awesome-phonenumber": "^2.65.0",
|
||||||
"axios": "^0.19.2",
|
"axios": "^0.24.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"brain.js": "^2.0.0-beta.2",
|
"brain.js": "^2.0.0-beta.4",
|
||||||
"bull": "^3.20.1",
|
"bull": "^4.1.1",
|
||||||
"cheerio": "^1.0.0-rc.5",
|
"cheerio": "^1.0.0-rc.10",
|
||||||
"cron": "^1.8.2",
|
"cron": "^1.8.2",
|
||||||
"eris": "^0.15.0",
|
"eris": "^0.16.1",
|
||||||
"eris-pagination": "github:bsian03/eris-pagination",
|
"eris-pagination": "github:libraryofcode/eris-pagination",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"helmet": "^3.22.0",
|
"helmet": "^4.6.0",
|
||||||
"ioredis": "^4.26.0",
|
"ioredis": "^4.28.2",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"mathjs": "^7.6.0",
|
"mathjs": "^10.0.0",
|
||||||
"moment": "^2.25.3",
|
"moment": "^2.29.1",
|
||||||
"mongoose": "^5.11.15",
|
"mongoose": "^6.1.1",
|
||||||
"nanoid": "^3.1.22",
|
"nanoid": "^3.1.30",
|
||||||
"nodemailer": "^6.4.8",
|
"nodemailer": "^6.7.2",
|
||||||
"pluris": "^0.2.5",
|
"pluris": "^0.3.7",
|
||||||
"puppeteer": "^5.5.0",
|
"puppeteer": "^12.0.1",
|
||||||
"sd-notify": "^2.8.0",
|
"sd-notify": "^2.8.0",
|
||||||
"signale": "^1.4.0",
|
"signale": "^1.4.0",
|
||||||
"stock-info": "^1.2.0",
|
"stock-info": "^1.5.1",
|
||||||
"stripe": "^8.120.0",
|
"stripe": "^8.193.0",
|
||||||
"uuid": "^8.0.0",
|
"uuid": "^8.3.2",
|
||||||
"yaml": "^1.9.2"
|
"yaml": "^1.10.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ export default class Report extends Route {
|
||||||
createdAt: new Date(mem.createdAt),
|
createdAt: new Date(mem.createdAt),
|
||||||
avatarURL: mem.avatarURL,
|
avatarURL: mem.avatarURL,
|
||||||
flags,
|
flags,
|
||||||
nitroBoost: mem.premiumSince === null,
|
nitroBoost: mem.premiumSince ?? null,
|
||||||
},
|
},
|
||||||
totalScore,
|
totalScore,
|
||||||
percentile: Math.round(this.server.client.util.percentile(set, report.total)),
|
percentile: Math.round(this.server.client.util.percentile(set, report.total)),
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { AxiosError, AxiosStatic } from 'axios';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Member, Message } from 'eris';
|
import { Member, Message } from 'eris';
|
||||||
import { Client, Command, RichEmbed } from '../class';
|
import { Client, Command, RichEmbed } from '../class';
|
||||||
|
import { CloudServicesUtil } from '../util';
|
||||||
|
|
||||||
export default class Apply extends Command {
|
export default class Apply extends Command {
|
||||||
public services: Map<string, { description: string, type: 'HARD' | 'SOFT', saaOnly?: boolean, url: string, validation: (...cond: any) => Promise<boolean> | boolean, func?: Function }>;
|
public services: Map<string, { description: string, type: 'HARD' | 'SOFT', saaOnly?: boolean, url: string, validation: (...cond: any) => Promise<boolean> | boolean, func?: Function }>;
|
||||||
|
@ -57,7 +58,12 @@ export default class Apply extends Command {
|
||||||
description: 'Tier 2 upgrade for Cloud Services account.',
|
description: 'Tier 2 upgrade for Cloud Services account.',
|
||||||
type: 'HARD',
|
type: 'HARD',
|
||||||
url: 'https://eds.libraryofcode.org/cs/t2',
|
url: 'https://eds.libraryofcode.org/cs/t2',
|
||||||
validation: (member: Member) => member.roles.includes('546457886440685578'),
|
validation: async (member: Member) => {
|
||||||
|
if (!member.roles.includes('546457886440685578')) return false;
|
||||||
|
const csAccount = await CloudServicesUtil.fetchAccountStatus(member.id, this.client.config.internalKey);
|
||||||
|
if (csAccount.tier > 2) return false;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
func: async (client: Client, ...data: any[]) => {
|
func: async (client: Client, ...data: any[]) => {
|
||||||
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||||
const ax = <AxiosStatic>require('axios');
|
const ax = <AxiosStatic>require('axios');
|
||||||
|
@ -68,6 +74,32 @@ export default class Apply extends Command {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.services.set('cs::temp-upgrade', {
|
||||||
|
description: 'Temporary Tier 3 upgrade for your Cloud Services account to install dependencies or RAM-dependent operations.',
|
||||||
|
type: 'SOFT',
|
||||||
|
url: 'https://eds.libraryofcode.org/cs/t3-temp',
|
||||||
|
validation: async (member: Member) => {
|
||||||
|
const csAccount = await CloudServicesUtil.fetchAccountStatus(member.id, this.client.config.internalKey);
|
||||||
|
// const memberCheck = await this.client.db.Member.findOne({ userID: member.id }).lean().exec();
|
||||||
|
// if (new Date() > memberCheck?.misc?.t3TemporaryExpiration?.date) return false;
|
||||||
|
if (csAccount.tier === 3) return false;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
func: async (client: Client, ...data: any[]) => {
|
||||||
|
const dmember = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||||
|
const member = await this.client.db.Member.findOne({ userID: dmember.id }).lean().exec();
|
||||||
|
if (!member) {
|
||||||
|
const addMember = new this.client.db.Member({
|
||||||
|
userID: dmember.id,
|
||||||
|
});
|
||||||
|
await addMember.save();
|
||||||
|
}
|
||||||
|
await this.client.db.Member.updateOne({ userID: dmember.id }, { $set: { misc: { t3TemporaryExpiration: { processed: false, date: new Date(Date.now() + 129600000) } } } });
|
||||||
|
|
||||||
|
await CloudServicesUtil.upgradeT2(dmember.id, this.client.config.internalKey);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
this.services.set('cs::promot3', {
|
this.services.set('cs::promot3', {
|
||||||
description: 'Receive 25% off your first purchase of Tier 3.',
|
description: 'Receive 25% off your first purchase of Tier 3.',
|
||||||
type: 'SOFT',
|
type: 'SOFT',
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
/* eslint-disable no-undef */
|
||||||
import { TextChannel } from 'eris';
|
import { TextChannel } from 'eris';
|
||||||
import { Client, RichEmbed } from '../class';
|
import { Client, RichEmbed } from '../class';
|
||||||
|
import { CloudServicesUtil } from '../util';
|
||||||
|
|
||||||
let interval: NodeJS.Timeout;
|
let interval: NodeJS.Timeout;
|
||||||
|
|
||||||
|
@ -8,6 +10,16 @@ export default function checkLock(client: Client): NodeJS.Timeout {
|
||||||
try {
|
try {
|
||||||
const moderations = await client.db.Moderation.find();
|
const moderations = await client.db.Moderation.find();
|
||||||
const judgements = await client.db.Judgement.find().lean().exec();
|
const judgements = await client.db.Judgement.find().lean().exec();
|
||||||
|
const members = await client.db.Member.find();
|
||||||
|
members.forEach(async (member) => {
|
||||||
|
if (member.misc?.t3TemporaryExpiration?.processed === false) {
|
||||||
|
if (new Date() > member.misc?.t3TemporaryExpiration?.date) {
|
||||||
|
await member.updateOne({ 'misc.t3TemporaryExpiration.processed': true });
|
||||||
|
|
||||||
|
await CloudServicesUtil.downgradeT2(member.id, client.config.internalKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
judgements.forEach(async (judgement) => {
|
judgements.forEach(async (judgement) => {
|
||||||
if (!judgement.expires) return;
|
if (!judgement.expires) return;
|
||||||
if (new Date() > judgement.expires) {
|
if (new Date() > judgement.expires) {
|
||||||
|
|
|
@ -2,15 +2,21 @@ import { Document, Schema, model } from 'mongoose';
|
||||||
|
|
||||||
export interface MemberInterface extends Document {
|
export interface MemberInterface extends Document {
|
||||||
userID: string,
|
userID: string,
|
||||||
additional: {
|
additional?: {
|
||||||
langs: ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'],
|
langs: ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'],
|
||||||
operatingSystems: ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'],
|
operatingSystems: ['arch', 'deb', 'cent', 'fedora', 'manjaro', 'mdarwin', 'redhat', 'ubuntu', 'win'],
|
||||||
github: string,
|
github: string,
|
||||||
gitlab: string,
|
gitlab: string,
|
||||||
bio: string,
|
bio: string,
|
||||||
},
|
},
|
||||||
|
misc?: {
|
||||||
|
t3TemporaryExpiration?: {
|
||||||
|
date: Date,
|
||||||
|
processed: boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
x509?: string,
|
x509?: string,
|
||||||
pgp?: string
|
pgp?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Member: Schema = new Schema({
|
const Member: Schema = new Schema({
|
||||||
|
@ -22,6 +28,12 @@ const Member: Schema = new Schema({
|
||||||
gitlab: String,
|
gitlab: String,
|
||||||
bio: String,
|
bio: String,
|
||||||
},
|
},
|
||||||
|
misc: {
|
||||||
|
t3TemporaryExpiration: {
|
||||||
|
date: Date,
|
||||||
|
processed: Boolean,
|
||||||
|
},
|
||||||
|
},
|
||||||
x509: String,
|
x509: String,
|
||||||
pgp: String,
|
pgp: String,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue