Skip to content

Commit 6b3657e

Browse files
committed
chore(): update from master
2 parents faf9bb2 + 5eb4f34 commit 6b3657e

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hawk.api",
3-
"version": "1.1.27",
3+
"version": "1.1.28",
44
"main": "index.ts",
55
"license": "UNLICENSED",
66
"scripts": {

src/models/eventsFactory.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ class EventsFactory extends Factory {
222222
$options: 'i',
223223
},
224224
},
225+
{
226+
'event.payload.addons': {
227+
$regex: escapedSearch,
228+
$options: 'i',
229+
},
230+
},
225231
],
226232
}
227233
: {};

src/models/project.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,20 @@ export default class ProjectModel extends AbstractModel<ProjectDBScheme> impleme
426426
/**
427427
* Toggles enabled state of the notifications rule
428428
* @param ruleId - rule id to update
429+
* @param status - new isEnabled status of the rule
429430
*/
430-
public async toggleNotificationsRuleEnabledState(ruleId: string): Promise<ProjectNotificationsRuleDBScheme | null> {
431+
public async toggleNotificationsRuleEnabledState(ruleId: string, status?: boolean): Promise<ProjectNotificationsRuleDBScheme | null> {
431432
const rule = this.notifications.find(_rule => _rule._id.toString() === ruleId);
432433

433434
if (!rule) {
434435
return null;
435436
}
436437

437-
rule.isEnabled = !rule.isEnabled;
438+
if (status !== undefined) {
439+
rule.isEnabled = status;
440+
} else {
441+
rule.isEnabled = !rule.isEnabled;
442+
}
438443

439444
const result = await this.collection.findOneAndUpdate(
440445
{

src/resolvers/projectNotifications.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,25 @@ export default {
242242

243243
return project.toggleNotificationsRuleEnabledState(input.ruleId);
244244
},
245+
246+
/**
247+
* Unsubscribes from notifications by disabling the rule
248+
* @param _obj - parent object
249+
* @param factories - factories for working with models
250+
* @param input - input data for unsubscribing
251+
*/
252+
async unsubscribeFromNotifications(
253+
_obj: undefined,
254+
{ input }: { input: ProjectNotificationsRulePointer },
255+
{ factories }: ResolverContextWithUser
256+
): Promise<ProjectNotificationsRuleDBScheme | null> {
257+
const project = await factories.projectsFactory.findById(input.projectId);
258+
259+
if (!project) {
260+
throw new ApolloError('No project with such id');
261+
}
262+
263+
return project.toggleNotificationsRuleEnabledState(input.ruleId, false);
264+
},
245265
},
246266
};

src/typeDefs/projectNotificationsMutations.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,13 @@ export default gql`
143143
"Data for toggling"
144144
input: ProjectNotificationRulePointer
145145
): ProjectNotificationsRule @requireAdmin
146+
147+
"""
148+
Unsubscribes from notifications by disabling the rule
149+
"""
150+
unsubscribeFromNotifications(
151+
"Data for unsubscribing"
152+
input: ProjectNotificationRulePointer!
153+
): ProjectNotificationsRule
146154
}
147155
`;

0 commit comments

Comments
 (0)