implemented option to allow guests to see wiki page
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -101,6 +101,7 @@ public class Constants {
|
||||
public static final String FULLTEXT = "fulltext";
|
||||
|
||||
public static final String GET = "GET";
|
||||
public static final String GUEST_ALLOWED = "guest_allowed";
|
||||
|
||||
public static final String HASH = "hash";
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ public class WikiPage implements Mappable {
|
||||
private final Map<Long,Member> members = new HashMap<>();
|
||||
private String content;
|
||||
private Set<String> dirtyFields = new HashSet<>();
|
||||
private boolean guestAllowed = false;
|
||||
|
||||
public WikiPage(long id, String title, int version, String content) {
|
||||
this.id = id;
|
||||
@@ -46,6 +47,15 @@ public class WikiPage implements Mappable {
|
||||
return Set.copyOf(dirtyFields);
|
||||
}
|
||||
|
||||
public boolean guestAllowed() {
|
||||
return guestAllowed;
|
||||
}
|
||||
|
||||
public void guestAllowed(boolean guestAllowed) {
|
||||
this.guestAllowed = guestAllowed;
|
||||
dirtyFields.add(GUEST_ALLOWED);
|
||||
}
|
||||
|
||||
public long id(){
|
||||
return id;
|
||||
}
|
||||
@@ -72,6 +82,10 @@ public class WikiPage implements Mappable {
|
||||
if (!(val instanceof String s)) throw invalidFieldException(CONTENT,"String");
|
||||
content(s);
|
||||
break;
|
||||
case GUEST_ALLOWED:
|
||||
if (!(val instanceof Boolean b)) throw invalidFieldException(GUEST_ALLOWED,"Boolean");
|
||||
guestAllowed(b);
|
||||
break;
|
||||
case MEMBERS:
|
||||
if (!(val instanceof JSONObject membersJson)) throw invalidFieldException(MEMBERS,"Json");
|
||||
for (var uid : membersJson.keySet()){
|
||||
@@ -131,6 +145,7 @@ public class WikiPage implements Mappable {
|
||||
return Map.of(
|
||||
ID,id,
|
||||
CONTENT,Map.of(SOURCE,content,RENDERED,markdown(content)),
|
||||
GUEST_ALLOWED,guestAllowed,
|
||||
MEMBERS,memberMap,
|
||||
TITLE,title,
|
||||
VERSION,version,
|
||||
|
||||
Reference in New Issue
Block a user