Skip to content

Commit 310b061

Browse files
committed
Removed currentCountQuery from limit service config for customIntegrations
ref BAE-331 ref https://ghost.slack.com/archives/C02G9E68C/p1750776240012249 Since the introduction of the `customIntegrations` limit, it was been treated as a `Flag` limit, which is a simple on/off limit. The query that was assigned to in the config has never been executed and is not found in use anywhere in our repos. To be able to let customers use a feature, which they have enabled, after we impose a limit for that feature, we're exploring the option to use `currentCountQuery` to overwrite the imposed limit if the feature is already being used. Having a query in the config for custom integrations messes with that idea, besides the fact that it's a pointless query.
1 parent c413b97 commit 310b061

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

packages/limit-service/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This module is intended to hold **all of the logic** for testing if site:
33
- would be over a given limit if they took an action (i.e. added one more thing, switched to a different limit)
44
- if they are over a limit already
5-
- consistent error messages explaining why the limit has been reached
5+
- consistent error messages explaining why the limit has been reached
66

77
## Install
88

@@ -54,7 +54,7 @@ const limits = {
5454
error: 'Email sending has been temporarily disabled whilst your account is under review.'
5555
},
5656
// following is a "max periodic" type of configuration
57-
// note if you use this configuration, the limit service has to also get a
57+
// note if you use this configuration, the limit service has to also get a
5858
// "subscription" parameter to work as expected
5959
// emails: {
6060
// maxPeriodic: 42,
@@ -69,7 +69,7 @@ const limits = {
6969
};
7070

7171
// This information is needed for the limit service to work with "max periodic" limits
72-
// The interval value has to be 'month' as thats the only interval that was needed for
72+
// The interval value has to be 'month' as that's the only interval that was needed for
7373
// current usecase
7474
// The startDate has to be in ISO 8601 format (https://en.wikipedia.org/wiki/ISO_8601)
7575
const subscription = {
@@ -155,12 +155,12 @@ db.transaction((transacting) => {
155155
### Types of limits
156156
At the moment there are four different types of limits that limit service allows to define. These types are:
157157
1. `flag` - is an "on/off" switch for certain feature. Example usecase: "disable all emails". It's identified by a `disabled: true` property in the "limits" configuration.
158-
2. `max` - checks if the maximum amount of the resource has been used up.Example usecase: "disable creating a staff user when maximum of 5 has been reached". To configure this limit add `max: NUMBER` to the configuration. The limits that support max checks are: `members`, `staff`, and `customIntegrations`
158+
2. `max` - checks if the maximum amount of the resource has been used up.Example usecase: "disable creating a staff user when maximum of 5 has been reached". To configure this limit add `max: NUMBER` to the configuration. The limits that support max checks are: `members`, and `staff`
159159
3. `maxPeriodic` - it's a variation of `max` type with a difference that the check is done over certain period of time. Example usecase: "disable sending emails when the sent emails count has acceded a limit for last billing period". To enable this limit define `maxPeriodic: NUMBER` in the limit configuration and provide a subscription configuration when initializing the limit service instance. The subscription object comes as a separate parameter and has to contain two properties: `startDate` and `interval`, where `startDate` is a date in ISO 8601 format and period is `'month'` (other values like `'year'` are not supported yet)
160-
4. `allowList` - checks if provided value is defined in configured "allowlist". Example usecase: "disable theme activation if it is not an official theme". To configure this limit define ` allowlist: ['VALUE_1', 'VALUE_2', 'VALUE_N']` property in the "limits" parameter.
160+
4. `allowList` - checks if provided value is defined in configured "allowlist". Example usecase: "disable theme activation if it is not an official theme". To configure this limit define ` allowlist: ['VALUE_1', 'VALUE_2', 'VALUE_N']` property in the "limits" parameter.
161161

162162
### Supported limits
163-
There's a limited amount of limits that are supported by limit service. The are defined by "key" property name in the "config" module. List of currently supported limit names: `members`, `staff`, `customIntegrations`, `emails`, `customThemes`, `uploads`.
163+
There's a limited amount of limits that are supported by limit service. The are defined by "key" property name in the "config" module. List of currently supported limit names: `members`, `staff`, `customIntegrations`, `emails`, `customThemes`, `uploads`.
164164

165165
All limits can act as `flag` or `allowList` types. Only certain (`members`, `staff`, and`customIntegrations`) can have a `max` limit. Only `emails` currently supports the `maxPeriodic` type of limit.
166166

@@ -217,6 +217,6 @@ Follow the instructions for the top-level repo.
217217

218218

219219

220-
# Copyright & License
220+
# Copyright & License
221221

222222
Copyright (c) 2013-2025 Ghost Foundation - Released under the [MIT license](LICENSE).

packages/limit-service/lib/config.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,7 @@ module.exports = {
4545
return result.length;
4646
}
4747
},
48-
customIntegrations: {
49-
currentCountQuery: async (knex) => {
50-
let result = await knex('integrations')
51-
.count('id', {as: 'count'})
52-
.whereNotIn('type', ['internal', 'builtin'])
53-
.first();
54-
55-
return result.count;
56-
}
57-
},
48+
customIntegrations: {},
5849
customThemes: {},
5950
uploads: {
6051
// NOTE: this function should not ever be used as for uploads we compare the size

0 commit comments

Comments
 (0)