Noop notifications for dev (#6671)
* Noop notifications for dev We rarely have notifications set up for development environments, this removes the error messages related to missing server notification services * Log actions in noop service * Add line breaks * Improve log messages * Ignore local config at all levels
This commit is contained in:
parent
222345f0c9
commit
1d2757e42b
|
@ -42,3 +42,6 @@ junit.xml
|
||||||
documentation.json
|
documentation.json
|
||||||
.eslintcache
|
.eslintcache
|
||||||
storybook-static
|
storybook-static
|
||||||
|
|
||||||
|
# Local app configuration
|
||||||
|
apps/**/config/local.json
|
||||||
|
|
|
@ -572,12 +572,12 @@ export default class MainBackground {
|
||||||
this.stateService
|
this.stateService
|
||||||
);
|
);
|
||||||
this.notificationsService = new NotificationsService(
|
this.notificationsService = new NotificationsService(
|
||||||
|
this.logService,
|
||||||
this.syncService,
|
this.syncService,
|
||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.environmentService,
|
this.environmentService,
|
||||||
logoutCallback,
|
logoutCallback,
|
||||||
this.logService,
|
|
||||||
this.stateService,
|
this.stateService,
|
||||||
this.authService,
|
this.authService,
|
||||||
this.messagingService
|
this.messagingService
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
config/local.json
|
|
|
@ -13,6 +13,8 @@ console.log("Renderer process config");
|
||||||
const envConfig = configurator.load(NODE_ENV);
|
const envConfig = configurator.load(NODE_ENV);
|
||||||
configurator.log(envConfig);
|
configurator.log(envConfig);
|
||||||
|
|
||||||
|
const ENV = process.env.ENV == null ? "development" : process.env.ENV;
|
||||||
|
|
||||||
const common = {
|
const common = {
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
@ -170,6 +172,7 @@ const renderer = {
|
||||||
chunkFilename: "[id].[contenthash].css",
|
chunkFilename: "[id].[contenthash].css",
|
||||||
}),
|
}),
|
||||||
new webpack.EnvironmentPlugin({
|
new webpack.EnvironmentPlugin({
|
||||||
|
ENV: ENV,
|
||||||
FLAGS: envConfig.flags,
|
FLAGS: envConfig.flags,
|
||||||
DEV_FLAGS: NODE_ENV === "development" ? envConfig.devFlags : {},
|
DEV_FLAGS: NODE_ENV === "development" ? envConfig.devFlags : {},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
!dev-server.shared.pem
|
!dev-server.shared.pem
|
||||||
config/local.json
|
|
||||||
stats.json
|
stats.json
|
||||||
|
|
|
@ -82,7 +82,7 @@ import { StateService as StateServiceAbstraction } from "@bitwarden/common/platf
|
||||||
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
import { AbstractStorageService } from "@bitwarden/common/platform/abstractions/storage.service";
|
||||||
import { ValidationService as ValidationServiceAbstraction } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService as ValidationServiceAbstraction } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
import { StateFactory } from "@bitwarden/common/platform/factories/state-factory";
|
||||||
import { flagEnabled } from "@bitwarden/common/platform/misc/flags";
|
import { devFlagEnabled, flagEnabled } from "@bitwarden/common/platform/misc/flags";
|
||||||
import { Account } from "@bitwarden/common/platform/models/domain/account";
|
import { Account } from "@bitwarden/common/platform/models/domain/account";
|
||||||
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
import { GlobalState } from "@bitwarden/common/platform/models/domain/global-state";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
|
import { AppIdService } from "@bitwarden/common/platform/services/app-id.service";
|
||||||
|
@ -94,6 +94,7 @@ import { EncryptServiceImplementation } from "@bitwarden/common/platform/service
|
||||||
import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/multithread-encrypt.service.implementation";
|
import { MultithreadEncryptServiceImplementation } from "@bitwarden/common/platform/services/cryptography/multithread-encrypt.service.implementation";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/services/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/services/environment.service";
|
||||||
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
|
import { FileUploadService } from "@bitwarden/common/platform/services/file-upload/file-upload.service";
|
||||||
|
import { NoopNotificationsService } from "@bitwarden/common/platform/services/noop-notifications.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
import { StateService } from "@bitwarden/common/platform/services/state.service";
|
||||||
import { ValidationService } from "@bitwarden/common/platform/services/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/services/validation.service";
|
||||||
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
import { WebCryptoFunctionService } from "@bitwarden/common/platform/services/web-crypto-function.service";
|
||||||
|
@ -529,14 +530,16 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: NotificationsServiceAbstraction,
|
provide: NotificationsServiceAbstraction,
|
||||||
useClass: NotificationsService,
|
useClass: devFlagEnabled("noopNotifications")
|
||||||
|
? NoopNotificationsService
|
||||||
|
: NotificationsService,
|
||||||
deps: [
|
deps: [
|
||||||
|
LogService,
|
||||||
SyncServiceAbstraction,
|
SyncServiceAbstraction,
|
||||||
AppIdServiceAbstraction,
|
AppIdServiceAbstraction,
|
||||||
ApiServiceAbstraction,
|
ApiServiceAbstraction,
|
||||||
EnvironmentServiceAbstraction,
|
EnvironmentServiceAbstraction,
|
||||||
LOGOUT_CALLBACK,
|
LOGOUT_CALLBACK,
|
||||||
LogService,
|
|
||||||
StateServiceAbstraction,
|
StateServiceAbstraction,
|
||||||
AuthServiceAbstraction,
|
AuthServiceAbstraction,
|
||||||
MessagingServiceAbstraction,
|
MessagingServiceAbstraction,
|
||||||
|
|
|
@ -8,7 +8,9 @@ export type SharedFlags = {
|
||||||
|
|
||||||
// required to avoid linting errors when there are no flags
|
// required to avoid linting errors when there are no flags
|
||||||
/* eslint-disable @typescript-eslint/ban-types */
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
export type SharedDevFlags = {};
|
export type SharedDevFlags = {
|
||||||
|
noopNotifications: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
function getFlags<T>(envFlags: string | T): T {
|
function getFlags<T>(envFlags: string | T): T {
|
||||||
if (typeof envFlags === "string") {
|
if (typeof envFlags === "string") {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import { NotificationsService as NotificationsServiceAbstraction } from "../../abstractions/notifications.service";
|
||||||
|
import { LogService } from "../abstractions/log.service";
|
||||||
|
|
||||||
|
export class NoopNotificationsService implements NotificationsServiceAbstraction {
|
||||||
|
constructor(private logService: LogService) {}
|
||||||
|
|
||||||
|
init(): Promise<void> {
|
||||||
|
this.logService.info(
|
||||||
|
"Initializing no-op notification service, no push notifications will be received"
|
||||||
|
);
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConnection(sync?: boolean): Promise<void> {
|
||||||
|
this.logService.info("Updating notification service connection");
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
reconnectFromActivity(): Promise<void> {
|
||||||
|
this.logService.info("Reconnecting notification service from activity");
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectFromInactivity(): Promise<void> {
|
||||||
|
this.logService.info("Disconnecting notification service from inactivity");
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,12 +28,12 @@ export class NotificationsService implements NotificationsServiceAbstraction {
|
||||||
private reconnectTimer: any = null;
|
private reconnectTimer: any = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private logService: LogService,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private appIdService: AppIdService,
|
private appIdService: AppIdService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private logoutCallback: (expired: boolean) => Promise<void>,
|
private logoutCallback: (expired: boolean) => Promise<void>,
|
||||||
private logService: LogService,
|
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private messagingService: MessagingService
|
private messagingService: MessagingService
|
||||||
|
|
Loading…
Reference in New Issue