Fix note adding

This commit is contained in:
KennyTV 2020-08-28 11:54:31 +02:00
parent 07a33e7599
commit 0918f80d53
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 7 additions and 1 deletions

View File

@ -509,7 +509,9 @@ public class ProjectsController extends HangarController {
ObjectNode note = messages.addObject();
note.put("message", content);
note.put("user", userService.getCurrentUser().getId());
projectDao.get().update(projectData.getProject()); // TODO check why this doesn't update notes
String json = projectData.getProject().getNotes().getJson().toString();
projectDao.get().updateNotes(json, projectData.getProject().getId());
return null;
}

View File

@ -1,5 +1,6 @@
package io.papermc.hangar.db.dao;
import io.papermc.hangar.db.customtypes.JSONB;
import io.papermc.hangar.db.model.ProjectsTable;
import io.papermc.hangar.db.model.UserProjectRolesTable;
import io.papermc.hangar.db.model.UsersTable;
@ -38,6 +39,9 @@ public interface ProjectDao {
"recommended_version_id = :recommendedVersionId, notes = :notes WHERE id = :id")
void update(@BindBean ProjectsTable project);
@SqlUpdate("UPDATE projects SET notes = cast(:notes as jsonb) WHERE id = :id") //TODO check why we have to cast and can't just update (this works tho)
void updateNotes(String notes, long id);
@SqlUpdate("DELETE FROM projects WHERE id = :id")
void delete(@BindBean ProjectsTable project);