Skip to content

Commit a287653

Browse files
authored
Merge pull request #4830 from coralproject/develop
v9.10.8
2 parents 0ac1f80 + a86813a commit a287653

File tree

9 files changed

+33
-17
lines changed

9 files changed

+33
-17
lines changed

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coralproject/talk",
3-
"version": "9.10.7",
3+
"version": "9.10.8",
44
"author": "The Coral Project",
55
"homepage": "https://coralproject.net/",
66
"sideEffects": [

common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "common",
3-
"version": "9.10.7",
3+
"version": "9.10.8",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "common",
3-
"version": "9.10.7",
3+
"version": "9.10.8",
44
"description": "",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coralproject/talk",
3-
"version": "9.10.7",
3+
"version": "9.10.8",
44
"author": "The Coral Project",
55
"homepage": "https://coralproject.net/",
66
"sideEffects": [

server/src/core/server/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,24 @@ const config = convict({
499499
default: ms("86400s"),
500500
env: "REDIS_CACHE_EXPIRY",
501501
},
502+
internal_notifications: {
503+
doc: "When true, will enable the in-page (internal) notifications systems",
504+
format: Boolean,
505+
default: true,
506+
env: "INTERNAL_NOTIFICATIONS",
507+
},
502508
notifications_poll_rate: {
503509
doc: "rate at which live notification updates should poll client side.",
504510
format: "ms",
505511
default: ms("3000s"),
506512
env: "NOTIFICATIONS_POLL_RATE",
507513
},
514+
external_notifications: {
515+
doc: "When true, will enable the external, forwarded notifications systems",
516+
format: Boolean,
517+
default: false,
518+
env: "EXTERNAL_NOTIFICATIONS",
519+
},
508520
external_notifications_api_url: {
509521
doc: "URL to forward notifications information to an external url.",
510522
format: "url",

server/src/core/server/graph/context.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ export default class GraphContext {
166166
this.mongo,
167167
this.redis,
168168
this.logger,
169-
// if external notifications are active, we
170-
// turn off the internal notifications
171-
!this.externalNotifications.active()
169+
!!this.config.get("internal_notifications") ||
170+
!this.externalNotifications.active()
172171
);
173172
}
174173
}

server/src/core/server/graph/resolvers/Settings.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,16 @@ export const Settings: GQLSettingsTypeResolver<Tenant> = {
9797
args,
9898
ctx
9999
) => {
100-
// if external notifications are active, we disable the in-page notifications
101-
if (ctx.externalNotifications.active()) {
102-
return {
103-
...inPageNotifications,
104-
active: false,
105-
};
106-
}
107-
return { ...inPageNotifications, active: true };
100+
// if we have the env var set to enable in-page (internal)
101+
// notifications, we are active
102+
//
103+
// otherwise, the default behaviour is to disable in-page
104+
// if we have external notifications enabled
105+
const active =
106+
!!ctx.config.get("internal_notifications") ||
107+
!ctx.externalNotifications.active();
108+
109+
return { ...inPageNotifications, active };
108110
},
109111
showUnmoderatedCounts: ({ showUnmoderatedCounts = true }) =>
110112
showUnmoderatedCounts,

server/src/core/server/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ class Server {
278278
this.mongo,
279279
this.redis,
280280
logger,
281-
!externalNotifications.active()
281+
!!this.config.get("internal_notifications") ||
282+
!externalNotifications.active()
282283
),
283284
});
284285

server/src/core/server/services/notifications/externalService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,21 @@ const CreateNotificationsMutation = `
7878
`;
7979

8080
export class ExternalNotificationsService {
81+
private _active: boolean;
8182
private url?: string | null;
8283
private apiKey?: string | null;
8384
private logger: Logger;
8485

8586
constructor(config: Config, logger: Logger) {
8687
this.logger = logger;
8788

89+
this._active = config.get("external_notifications");
8890
this.url = config.get("external_notifications_api_url");
8991
this.apiKey = config.get("external_notifications_api_key");
9092
}
9193

9294
public active(): boolean {
93-
return !!(this.url && this.apiKey);
95+
return !!(this._active && this.url && this.apiKey);
9496
}
9597

9698
private userToExternalProfile(user: User): ExternalUserProfile {

0 commit comments

Comments
 (0)