diff --git a/src/backend/Environment.ts b/src/backend/Environment.ts index 85bdb7c2..3a059b94 100644 --- a/src/backend/Environment.ts +++ b/src/backend/Environment.ts @@ -1,6 +1,4 @@ /** * Keeps the environment context */ -export const ServerEnvironment = { - sendMailAvailable: false -}; +export const ServerEnvironment: { sendMailAvailable?: boolean } = {}; diff --git a/src/backend/model/database/SearchManager.ts b/src/backend/model/database/SearchManager.ts index 48755562..5e60b33c 100644 --- a/src/backend/model/database/SearchManager.ts +++ b/src/backend/model/database/SearchManager.ts @@ -382,8 +382,9 @@ export class SearchManager { case SortingMethods.random: if (Config.Database.type === DatabaseType.mysql) { query.groupBy('RAND(), media.id'); + } else { + query.groupBy('RANDOM()'); } - query.groupBy('RANDOM()'); break; } } diff --git a/src/common/config/private/Config.ts b/src/common/config/private/Config.ts index b8b74d40..7f1f01b7 100644 --- a/src/common/config/private/Config.ts +++ b/src/common/config/private/Config.ts @@ -7,8 +7,6 @@ import {IConfigClass} from 'typeconfig/common'; import {PasswordHelper} from '../../../backend/model/PasswordHelper'; import {TAGS} from '../public/ClientConfig'; import {ServerEnvironment} from '../../../backend/Environment'; -import {EmailMessagingType} from './MessagingConfig'; -import {Logger} from '../../../backend/Logger'; declare const process: any; @@ -82,7 +80,9 @@ export class PrivateConfigClass extends ServerConfig { require('../../../../package.json').buildCommitHash; this.Environment.upTime = upTime; this.Environment.isDocker = !!process.env.PI_DOCKER; - this.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable; + if (typeof ServerEnvironment.sendMailAvailable !== 'undefined') { + this.Environment.sendMailAvailable = ServerEnvironment.sendMailAvailable; + } } async original(): Promise {