Skip to content

Commit

Permalink
now back is working, need front
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Mariotti committed Dec 11, 2024
1 parent 99aa6fd commit 935274d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,18 @@ public void notifyBoardUsers(HttpServerRequest request) {
UserUtils.getUserInfos(eb, request, user -> {
String boardId = request.getParam(Field.BOARDID);
boardService.getBoardSharedUsers(boardId)
.onSuccess(usersIdsList -> {
.onSuccess(board -> {
JsonObject params = new JsonObject();
params.put(Field.BOARDURL, "/magneto#/board/view/")
.put(Field.BOARDNAME, );
timelineHelper.notifyTimeline(request, "magneto.notify_board", user, usersIdsList, params);
params.put(Field.BOARDURL, "/magneto#/board/" + boardId + "/view/")
.put(Field.BOARDNAME, board.getString(Field.TITLE));

List<String> userIdsList = board.getJsonArray(Field.SHARED).stream()
.filter(JsonObject.class::isInstance)
.map(obj -> ((JsonObject) obj).getString(Field.USERID))
.distinct()
.collect(Collectors.toList());

notification.notifyTimeline(request, "magneto.notify_board", user, userIdsList, params);
})
.onFailure(fail -> {
String message = String.format("[Magneto@%s::notifyBoardUsers] Failed to notify users of board : %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,5 @@ public class Field {
//notification Folder
public static final String FOLDERTITLE = "folderTitle";
public static final String FOLDERURL = "folderUrl";
public static final String BOARDNAME = "boardName";
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public interface BoardService {
*/
Future<List<Board>> getBoards(List<String> boardIds);

/**
* Get board title ans shared array by id
*
* @param boardId Board id to get data
* @return Future {@link Future <JsonArray>} containing the board title and its list of shared users and rights
*/
Future<JsonObject> getBoardSharedUsers(String boardId);

/**
* Get all boards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,24 +419,20 @@ public Future<List<Board>> getBoards(List<String> boardIds) {
}

@Override
public Future<List<String>> getBoardSharedUsers(string boardId){
Promise<List<String>> promise = Promise.promise();
public Future<JsonObject> getBoardSharedUsers(String boardId){
Promise<JsonObject> promise = Promise.promise();
JsonObject query = this.getBoardById(boardId);
mongoDb.command(query.toString(), MongoDbResult.validResultHandler(either -> {
if (either.isLeft()) {
log.error("[Magneto@%s::getBoardSharedUsers] Failed to get all board shared users : %s", this.getClass().getSimpleName(),
either.left().getValue());
promise.fail(either.left().getValue());
} else {
JsonArray shared = either.right().getValue()
.getJsonArray(Field.SHARED, new JsonArray());

List<String> userIdsList = shared.stream()
.filter(JsonObject.class::isInstance)
.map(obj -> ((JsonObject) obj).getJsonObject("userId"))
.distinct()
.collect(Collectors.toList());
promise.complete();
JsonArray result = either.right().getValue()
.getJsonObject(Field.CURSOR, new JsonObject())
.getJsonArray(Field.FIRSTBATCH, new JsonArray());

promise.complete(result.getJsonObject(0));
}
}));
return promise.future();
Expand Down Expand Up @@ -776,6 +772,7 @@ private JsonObject getBoardById(String boardId) {
.put(Field._ID, new JsonObject().put(Mongo.IN, new JsonArray().add(boardId))))
.project(new JsonObject()
.put(Field._ID, 1)
.put(Field.TITLE, 1)
.put(Field.SHARED, 1));
return query.getAggregate();
}
Expand Down

0 comments on commit 935274d

Please sign in to comment.