chore: global sync per minute safety limit (#2765)
This commit is contained in:
@@ -16,13 +16,14 @@ const MaximumSyncOptions = {
|
||||
let GlobalSubscriptionIdCounter = 1001
|
||||
|
||||
export class AppContext {
|
||||
constructor({ identifier, crypto, email, password, passcode, host } = {}) {
|
||||
constructor({ identifier, crypto, email, password, passcode, host, syncCallsThresholdPerMinute } = {}) {
|
||||
this.identifier = identifier || `${Math.random()}`
|
||||
this.crypto = crypto
|
||||
this.email = email || UuidGenerator.GenerateUuid()
|
||||
this.password = password || UuidGenerator.GenerateUuid()
|
||||
this.passcode = passcode || 'mypasscode'
|
||||
this.host = host || Defaults.getDefaultHost()
|
||||
this.syncCallsThresholdPerMinute = syncCallsThresholdPerMinute
|
||||
}
|
||||
|
||||
enableLogging() {
|
||||
@@ -46,6 +47,7 @@ export class AppContext {
|
||||
undefined,
|
||||
this.host,
|
||||
this.crypto || new FakeWebCrypto(),
|
||||
this.syncCallsThresholdPerMinute,
|
||||
)
|
||||
|
||||
this.application.dependencies.get(TYPES.Logger).setLevel('error')
|
||||
|
||||
@@ -2,7 +2,7 @@ import WebDeviceInterface from './web_device_interface.js'
|
||||
import FakeWebCrypto from './fake_web_crypto.js'
|
||||
import * as Defaults from './Defaults.js'
|
||||
|
||||
export function createApplicationWithOptions({ identifier, environment, platform, host, crypto, device }) {
|
||||
export function createApplicationWithOptions({ identifier, environment, platform, host, crypto, device, syncCallsThresholdPerMinute }) {
|
||||
if (!device) {
|
||||
device = new WebDeviceInterface()
|
||||
device.environment = environment
|
||||
@@ -22,11 +22,12 @@ export function createApplicationWithOptions({ identifier, environment, platform
|
||||
defaultHost: host || Defaults.getDefaultHost(),
|
||||
appVersion: Defaults.getAppVersion(),
|
||||
webSocketUrl: Defaults.getDefaultWebSocketUrl(),
|
||||
syncCallsThresholdPerMinute,
|
||||
})
|
||||
}
|
||||
|
||||
export function createApplication(identifier, environment, platform, host, crypto) {
|
||||
return createApplicationWithOptions({ identifier, environment, platform, host, crypto })
|
||||
export function createApplication(identifier, environment, platform, host, crypto, syncCallsThresholdPerMinute) {
|
||||
return createApplicationWithOptions({ identifier, environment, platform, host, crypto, syncCallsThresholdPerMinute })
|
||||
}
|
||||
|
||||
export function createApplicationWithFakeCrypto(identifier, environment, platform, host) {
|
||||
|
||||
@@ -43,16 +43,16 @@ export async function createAndInitSimpleAppContext(
|
||||
}
|
||||
}
|
||||
|
||||
export async function createAppContextWithFakeCrypto(identifier, email, password) {
|
||||
return createAppContext({ identifier, crypto: new FakeWebCrypto(), email, password })
|
||||
export async function createAppContextWithFakeCrypto(identifier, email, password, syncCallsThresholdPerMinute) {
|
||||
return createAppContext({ identifier, crypto: new FakeWebCrypto(), email, password, syncCallsThresholdPerMinute })
|
||||
}
|
||||
|
||||
export async function createAppContextWithRealCrypto(identifier) {
|
||||
return createAppContext({ identifier, crypto: new SNWebCrypto() })
|
||||
}
|
||||
|
||||
export async function createAppContext({ identifier, crypto, email, password, host } = {}) {
|
||||
const context = new AppContext({ identifier, crypto, email, password, host })
|
||||
export async function createAppContext({ identifier, crypto, email, password, host, syncCallsThresholdPerMinute } = {}) {
|
||||
const context = new AppContext({ identifier, crypto, email, password, host, syncCallsThresholdPerMinute })
|
||||
await context.initialize()
|
||||
return context
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user