[Notice] Announcing the End of Demo Server [Read me]
noti: Reset user noti settings when to unwatch a project
@dc4a984280309025d86cc7104350304f8a30841f
--- app/controllers/WatchProjectApp.java
+++ app/controllers/WatchProjectApp.java
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 |
import utils.ErrorViews; |
23 | 23 |
|
24 | 24 |
import static models.UserProjectNotification.*; |
25 |
+import static models.enumeration.ResourceType.PROJECT; |
|
25 | 26 |
|
26 | 27 |
@AnonymousCheck(requiresLogin = true, displaysFlashMessage = true) |
27 | 28 |
public class WatchProjectApp extends Controller { |
... | ... | @@ -36,9 +37,12 @@ |
36 | 37 |
|
37 | 38 |
@IsAllowed(Operation.READ) |
38 | 39 |
@Transactional |
39 |
- public static Result unwatch(String userName, String projectName) { |
|
40 |
- Project project = Project.findByOwnerAndProjectName(userName, projectName); |
|
40 |
+ public static Result unwatch(String loginId, String projectName) { |
|
41 |
+ Project project = Project.findByOwnerAndProjectName(loginId, projectName); |
|
42 |
+ |
|
41 | 43 |
Watch.unwatch(project.asResource()); |
44 |
+ |
|
45 |
+ UserProjectNotification.deleteUnwatchedProjectNotifications(UserApp.currentUser(), project); |
|
42 | 46 |
return ok(); |
43 | 47 |
} |
44 | 48 |
|
--- app/models/UserProjectNotification.java
+++ app/models/UserProjectNotification.java
... | ... | @@ -165,4 +165,14 @@ |
165 | 165 |
} |
166 | 166 |
return users; |
167 | 167 |
} |
168 |
+ |
|
169 |
+ public static void deleteUnwatchedProjectNotifications(User user, Project project){ |
|
170 |
+ List<UserProjectNotification> userProjectNotifications = find.where() |
|
171 |
+ .eq("user.id", user.id) |
|
172 |
+ .eq("project.id", project.id) |
|
173 |
+ .findList(); |
|
174 |
+ for (UserProjectNotification notification : userProjectNotifications) { |
|
175 |
+ notification.delete(); |
|
176 |
+ } |
|
177 |
+ } |
|
168 | 178 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?