implemented project creation
This commit is contained in:
@@ -27,7 +27,6 @@ import de.srsoftware.umbrella.user.api.UserDb;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class LegacyApi extends BaseHandler {
|
||||
@@ -129,22 +128,16 @@ public class LegacyApi extends BaseHandler {
|
||||
throw new UmbrellaException(400,"Fetching related users not implemented, yet!");
|
||||
}
|
||||
|
||||
List<UmbrellaUser> userList = new ArrayList<>();
|
||||
if (ids.isEmpty()) {
|
||||
userList = users.list(0, null);
|
||||
} else {
|
||||
for (var id : ids){
|
||||
try {
|
||||
userList.add(users.load(id));
|
||||
} catch (UmbrellaException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arrayPassed || userList.size() != 1) {
|
||||
Map<Long, Map<String, Object>> userData = userList.stream().collect(Collectors.toMap(UmbrellaUser::id, UmbrellaUser::toMap));
|
||||
Map<Long, UmbrellaUser> userMap = users.list(0, null, ids);
|
||||
if (arrayPassed || userMap.size() != 1) {
|
||||
var userData = new HashMap<Long, Map<String, Object>>();
|
||||
for (var entry : userMap.entrySet()) userData.put(entry.getKey(),entry.getValue().toMap());
|
||||
return sendContent(ex,userData);
|
||||
}
|
||||
return sendContent(ex, userList.getFirst().toMap());
|
||||
for (var entry : userMap.entrySet()){
|
||||
return sendContent(ex,entry.getValue());
|
||||
}
|
||||
throw UmbrellaException.notFound("Failed to load user(s) for id(s): {0}",ids);
|
||||
}
|
||||
|
||||
private boolean legacyNotify(HttpExchange ex) throws UmbrellaException, IOException {
|
||||
@@ -187,8 +180,8 @@ public class LegacyApi extends BaseHandler {
|
||||
}
|
||||
}
|
||||
if (!recipients.isEmpty()){ // replace legacy user ids by user objects in receivers field
|
||||
List<UmbrellaUser> resp = users.list(0, null, recipients.toArray(new Long[0]));
|
||||
data.put("receivers",resp.stream().map(UmbrellaUser::toMap).toList());
|
||||
Map<Long, UmbrellaUser> resp = users.list(0, null, recipients);
|
||||
data.put("receivers",resp.values().stream().map(UmbrellaUser::toMap).toList());
|
||||
}
|
||||
|
||||
if (!data.has(SENDER)) data.put(SENDER,user.toMap());
|
||||
|
||||
Reference in New Issue
Block a user