je sais vraiment pas ce que j'ai ajouté mais amélioration jt'e jure
This commit is contained in:
		@ -80,7 +80,7 @@ public class ForumController {
 | 
			
		||||
	public ResponseEntity<Topic> postTopicToForum(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Topic data){
 | 
			
		||||
		User u = authServ.getUserFromToken(token);
 | 
			
		||||
		Forum f = forumRepo.findById(id).orElse(null);
 | 
			
		||||
		if(!(f.getWriters().contains(u) || u.getRole() == Role.Admin)){
 | 
			
		||||
		if(!(f.getWriters().contains(u) || f.getCourse().getOwner().equals(u) || u.getRole() == Role.Admin)){
 | 
			
		||||
			return new UnauthorizedResponse<>(null);
 | 
			
		||||
		}
 | 
			
		||||
		forumServ.createTopic(f, data);
 | 
			
		||||
 | 
			
		||||
@ -28,10 +28,11 @@ public class Course {
 | 
			
		||||
    private User owner;
 | 
			
		||||
 | 
			
		||||
	//// Extension Messagerie /////
 | 
			
		||||
	@OneToMany(cascade = CascadeType.ALL)
 | 
			
		||||
	@OneToMany(mappedBy = "course", cascade = CascadeType.ALL)
 | 
			
		||||
	private List<Forum> forums;
 | 
			
		||||
 | 
			
		||||
	public void addForum(Forum f){
 | 
			
		||||
		f.setCourse(this);
 | 
			
		||||
		forums.add(f);
 | 
			
		||||
	}
 | 
			
		||||
	///////////////////////////////
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,8 @@ package ovh.herisson.Clyde.Tables.Msg;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonIgnore;
 | 
			
		||||
 | 
			
		||||
import jakarta.persistence.*;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import ovh.herisson.Clyde.Tables.Course;
 | 
			
		||||
@ -16,6 +18,7 @@ public class Forum {
 | 
			
		||||
	private int id;
 | 
			
		||||
 | 
			
		||||
	@ManyToOne
 | 
			
		||||
	@JsonIgnore
 | 
			
		||||
	private Course course;
 | 
			
		||||
 | 
			
		||||
	private String name;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user