Add transactions to methods in ForumManager

This commit is contained in:
Torsten Grote
2021-01-05 11:19:44 -03:00
parent 04517e942e
commit a9cd40faeb
2 changed files with 23 additions and 2 deletions

View File

@@ -74,6 +74,11 @@ public interface ForumManager {
*/
Collection<Forum> getForums() throws DbException;
/**
* Returns all forums to which the user subscribes.
*/
Collection<Forum> getForums(Transaction txn) throws DbException;
/**
* Returns the text of the forum post with the given ID.
*/
@@ -92,8 +97,14 @@ public interface ForumManager {
/**
* Returns the group count for the given forum.
*/
@Deprecated
GroupCount getGroupCount(GroupId g) throws DbException;
/**
* Returns the group count for the given forum.
*/
GroupCount getGroupCount(Transaction txn, GroupId g) throws DbException;
/**
* Marks a message as read or unread and updates the group count.
*/

View File

@@ -165,8 +165,12 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
@Override
public Collection<Forum> getForums() throws DbException {
Collection<Group> groups = db.transactionWithResult(true, txn ->
db.getGroups(txn, CLIENT_ID, MAJOR_VERSION));
return db.transactionWithResult(true, this::getForums);
}
@Override
public Collection<Forum> getForums(Transaction txn) throws DbException {
Collection<Group> groups = db.getGroups(txn, CLIENT_ID, MAJOR_VERSION);
try {
List<Forum> forums = new ArrayList<>();
for (Group g : groups) forums.add(parseForum(g));
@@ -235,6 +239,12 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
return messageTracker.getGroupCount(g);
}
@Override
public GroupCount getGroupCount(Transaction txn, GroupId g)
throws DbException {
return messageTracker.getGroupCount(txn, g);
}
@Override
public void setReadFlag(GroupId g, MessageId m, boolean read)
throws DbException {