Skip to content

Commit

Permalink
TopicPermissionService -> Scala
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcom committed Oct 29, 2024
1 parent e0d8704 commit 7fca0f0
Show file tree
Hide file tree
Showing 11 changed files with 448 additions and 521 deletions.
4 changes: 2 additions & 2 deletions src/main/java/ru/org/linux/group/GroupListDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public GroupListDao(UserService userService, TopicTagService topicTagService, Da
"t.deleted, " +
"t.postscore as topic_postscore " +
"FROM topics AS t JOIN comments ON (t.id=comments.topic) " +
"WHERE t.postscore IS DISTINCT FROM " + TopicPermissionService.POSTSCORE_HIDE_COMMENTS + " " +
"WHERE t.postscore IS DISTINCT FROM " + TopicPermissionService.POSTSCORE_HIDE_COMMENTS() + " " +
"AND comments.id=(SELECT id FROM comments WHERE NOT deleted AND comments.topic=t.id " +
"%s" + /* user!=null ? queryCommentIgnored */
"%s" + // queryAuthorFilter
Expand Down Expand Up @@ -291,7 +291,7 @@ private List<TopicsListItem> load(String partFilter, Optional<User> currentUserO
tags = topicTagService.getTagsForTitle(msgid);

int topicPostscore = (resultSet.getObject("topic_postscore") == null)
? TopicPermissionService.POSTSCORE_UNRESTRICTED
? TopicPermissionService.POSTSCORE_UNRESTRICTED()
: resultSet.getInt("topic_postscore");

res.add(new TopicsListItem(author, msgid, lastmod, stat1,
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/ru/org/linux/group/TopicsListItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1998-2022 Linux.org.ru
* Copyright 1998-2024 Linux.org.ru
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -108,7 +108,7 @@ public Timestamp getLastmod() {
}

public int getCommentCount() {
if (topicPostscore != TopicPermissionService.POSTSCORE_HIDE_COMMENTS) {
if (topicPostscore != TopicPermissionService.POSTSCORE_HIDE_COMMENTS()) {
return stat1;
} else {
return 0;
Expand Down Expand Up @@ -176,6 +176,6 @@ public boolean isSticky() {
}

public boolean isCommentsClosed() {
return topicPostscore >= TopicPermissionService.POSTSCORE_MODERATORS_ONLY;
return topicPostscore >= TopicPermissionService.POSTSCORE_MODERATORS_ONLY();
}
}
6 changes: 3 additions & 3 deletions src/main/java/ru/org/linux/section/Section.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1998-2022 Linux.org.ru
* Copyright 1998-2024 Linux.org.ru
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -62,7 +62,7 @@ public Section(ResultSet rs) throws SQLException {
if (!rs.wasNull()) {
topicsRestriction = restrictTopicsValue;
} else {
topicsRestriction = TopicPermissionService.POSTSCORE_UNRESTRICTED;
topicsRestriction = TopicPermissionService.POSTSCORE_UNRESTRICTED();
}

scrollMode = SectionScrollModeEnum.valueOf(rs.getString("scroll_mode"));
Expand Down Expand Up @@ -110,7 +110,7 @@ public String getTitle() {
public static int getCommentPostscore(int id) {
//TODO move this to database
if (id == SECTION_NEWS || id == SECTION_FORUM) {
return TopicPermissionService.POSTSCORE_UNRESTRICTED;
return TopicPermissionService.POSTSCORE_UNRESTRICTED();
} else if (id == SECTION_ARTICLES || id == SECTION_GALLERY) {
return 45;
} else {
Expand Down
Loading

0 comments on commit 7fca0f0

Please sign in to comment.