Skip to content

Commit 6f90397

Browse files
feat(Discussion): Hide inappropriate posts in real-time
1 parent 36909d0 commit 6f90397

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/main/java/org/wise/portal/spring/data/redis/RedisMessageSubscriber.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public void onMessage(Message message, byte[] pattern) {
3737
createAndSendWebSocketMessage("newStudentAchievement", messageJSON, "achievement");
3838
break;
3939
case "annotationToStudent":
40+
case "annotationToClassroom":
4041
createAndSendWebSocketMessage("annotation", messageJSON, "annotation");
4142
break;
4243
case "notification":

src/main/java/org/wise/vle/web/wise5/TeacherPostDataController.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@ private void sendAnnotationNotificationToStudent(Annotation annotation) {
174174
try {
175175
Notification notification = this.createNotificationForAnnotation(annotation);
176176
Long toWorkgroupId = notification.getToWorkgroup().getId();
177-
broadcastAnnotationToStudent(toWorkgroupId, annotation);
178-
broadcastNotificationToStudent(toWorkgroupId, notification);
177+
this.broadcastAnnotationToStudent(toWorkgroupId, annotation);
178+
if (annotation.getType().equals("inappropriateFlag")) {
179+
this.broadcastAnnotationToClassroom(annotation);
180+
}
181+
this.broadcastNotificationToStudent(toWorkgroupId, notification);
179182
} catch (Exception e) {
180183
e.printStackTrace();
181184
}
@@ -217,7 +220,7 @@ private Notification createNotificationForAnnotation(Annotation annotation) {
217220
return notification;
218221
}
219222

220-
public void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotation)
223+
private void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotation)
221224
throws JSONException {
222225
annotation.convertToClientAnnotation();
223226
JSONObject message = new JSONObject();
@@ -227,7 +230,17 @@ public void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotati
227230
redisPublisher.publish(message.toString());
228231
}
229232

230-
public void broadcastNotificationToStudent(Long toWorkgroupId, Notification notification)
233+
private void broadcastAnnotationToClassroom(Annotation annotation) throws JSONException {
234+
annotation.convertToClientAnnotation();
235+
JSONObject message = new JSONObject();
236+
message.put("type", "annotationToClassroom");
237+
message.put("topic", String.format("/topic/classroom/%s/%s", annotation.getRun().getId(),
238+
annotation.getPeriod().getId()));
239+
message.put("annotation", annotation.toJSON());
240+
redisPublisher.publish(message.toString());
241+
}
242+
243+
private void broadcastNotificationToStudent(Long toWorkgroupId, Notification notification)
231244
throws JSONException {
232245
notification.convertToClientNotification();
233246
JSONObject message = new JSONObject();
@@ -236,4 +249,5 @@ public void broadcastNotificationToStudent(Long toWorkgroupId, Notification noti
236249
message.put("notification", notification.toJSON());
237250
redisPublisher.publish(message.toString());
238251
}
252+
239253
}

0 commit comments

Comments
 (0)