re-adding env var controls for cloud limit functionality
This commit is contained in:
parent
5b1ae778da
commit
757fbbc19c
|
@ -1,6 +1,6 @@
|
||||||
const CouchDB = require("../db")
|
const CouchDB = require("../db")
|
||||||
const usageQuota = require("../utilities/usageQuota")
|
const usageQuota = require("../utilities/usageQuota")
|
||||||
// const env = require("../environment")
|
const env = require("../environment")
|
||||||
|
|
||||||
// currently only counting new writes and deletes
|
// currently only counting new writes and deletes
|
||||||
const METHOD_MAP = {
|
const METHOD_MAP = {
|
||||||
|
@ -29,9 +29,9 @@ function getProperty(url) {
|
||||||
|
|
||||||
module.exports = async (ctx, next) => {
|
module.exports = async (ctx, next) => {
|
||||||
// if in development or a self hosted cloud usage quotas should not be executed
|
// if in development or a self hosted cloud usage quotas should not be executed
|
||||||
// if (env.isDev() || env.SELF_HOSTED) {
|
if (env.isDev() || env.SELF_HOSTED) {
|
||||||
// return next()
|
return next()
|
||||||
// }
|
}
|
||||||
|
|
||||||
const db = new CouchDB(ctx.appId)
|
const db = new CouchDB(ctx.appId)
|
||||||
let usage = METHOD_MAP[ctx.req.method]
|
let usage = METHOD_MAP[ctx.req.method]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// const env = require("../environment")
|
const env = require("../environment")
|
||||||
const { getGlobalDB } = require("@budibase/auth/tenancy")
|
const { getGlobalDB } = require("@budibase/auth/tenancy")
|
||||||
|
|
||||||
function getNewQuotaReset() {
|
function getNewQuotaReset() {
|
||||||
|
@ -23,9 +23,10 @@ exports.Properties = {
|
||||||
* also been reset after this call.
|
* also been reset after this call.
|
||||||
*/
|
*/
|
||||||
exports.update = async (property, usage) => {
|
exports.update = async (property, usage) => {
|
||||||
// if (!env.USE_QUOTAS) {
|
if (!env.USE_QUOTAS) {
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const db = getGlobalDB()
|
const db = getGlobalDB()
|
||||||
const quota = await db.get("usage_quota")
|
const quota = await db.get("usage_quota")
|
||||||
|
|
|
@ -17,7 +17,7 @@ const {
|
||||||
tryAddTenant,
|
tryAddTenant,
|
||||||
updateTenantId,
|
updateTenantId,
|
||||||
} = require("@budibase/auth/tenancy")
|
} = require("@budibase/auth/tenancy")
|
||||||
// const env = require("../../../environment")
|
const env = require("../../../environment")
|
||||||
|
|
||||||
const PLATFORM_INFO_DB = StaticDatabases.PLATFORM_INFO.name
|
const PLATFORM_INFO_DB = StaticDatabases.PLATFORM_INFO.name
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ exports.adminUser = async ctx => {
|
||||||
)
|
)
|
||||||
|
|
||||||
// write usage quotas for cloud
|
// write usage quotas for cloud
|
||||||
// if (!env.SELF_HOSTED) {
|
if (!env.SELF_HOSTED) {
|
||||||
await db.post({
|
await db.post({
|
||||||
_id: "usage_quota",
|
_id: "usage_quota",
|
||||||
quotaReset: Date.now() + 2592000000,
|
quotaReset: Date.now() + 2592000000,
|
||||||
|
@ -162,7 +162,7 @@ exports.adminUser = async ctx => {
|
||||||
emails: 50,
|
emails: 50,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (response.rows.some(row => row.doc.admin)) {
|
if (response.rows.some(row => row.doc.admin)) {
|
||||||
ctx.throw(
|
ctx.throw(
|
||||||
|
|
|
@ -112,8 +112,10 @@ async function getSmtpConfiguration(db, workspaceId = null) {
|
||||||
params.workspace = workspaceId
|
params.workspace = workspaceId
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!env.SMTP_FALLBACK_ENABLED) {
|
const customConfig = getScopedConfig(db, params)
|
||||||
return getScopedConfig(db, params)
|
|
||||||
|
if (customConfig && !env.SMTP_FALLBACK_ENABLED) {
|
||||||
|
return customConfig
|
||||||
} else {
|
} else {
|
||||||
// Use an SMTP fallback configuration from env variables
|
// Use an SMTP fallback configuration from env variables
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue