message by user
This commit is contained in:
parent
905fc40851
commit
a88079f5fa
22
src/main/java/com/covas/Json/MessageByUser.java
Normal file
22
src/main/java/com/covas/Json/MessageByUser.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.covas.Json;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.covas.Entity.MessageEntity;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class MessageByUser {
|
||||
|
||||
public final String pseudo;
|
||||
public final Collection<MessageEntity> message;
|
||||
|
||||
public MessageByUser(String pseudo, Collection<MessageEntity> message){
|
||||
this.pseudo = pseudo;
|
||||
this.message = message;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ import com.covas.Entity.CommentEntity;
|
||||
import com.covas.Entity.MessageEntity;
|
||||
import com.covas.Entity.PublisherEntity;
|
||||
import com.covas.Entity.UsersEntity;
|
||||
import com.covas.Json.MessageByUser;
|
||||
|
||||
import io.quarkus.panache.common.Page;
|
||||
import io.quarkus.panache.common.Parameters;
|
||||
@ -140,6 +141,31 @@ public class MessageRessources {
|
||||
return responseHttp;
|
||||
}
|
||||
|
||||
@GET
|
||||
@RolesAllowed("User")
|
||||
@Path("info")
|
||||
public Response getInfoMessage(@Context SecurityContext ctx, @CookieParam("user") String userCookie) {
|
||||
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
||||
UsersEntity user = UsersEntity.findById(kid);
|
||||
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||
if (status.equals(Response.Status.OK)) {
|
||||
if (user == null) {
|
||||
status = Response.Status.NOT_FOUND;
|
||||
}
|
||||
if (!checkUserCookie(userCookie, user)) {
|
||||
status = Response.Status.FORBIDDEN;
|
||||
}
|
||||
}
|
||||
Response responseHttp = Response.status(status).build();
|
||||
|
||||
if (status.equals(Response.Status.OK)) {
|
||||
responseHttp = Response.status(status).entity(new MessageByUser(user.pseudo, user.message))
|
||||
.build();
|
||||
}
|
||||
return responseHttp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// PUT
|
||||
@PUT
|
||||
|
Loading…
x
Reference in New Issue
Block a user