Merge "Show banner after dismissal if message is updated"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java b/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java
index b90d4a7..d1ec85a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/messageoftheday/GetMessage.java
@@ -69,8 +69,8 @@
return null;
}
- motd.id = cfg.getString(SECTION_MESSAGE, null, KEY_ID);
- if (Strings.isNullOrEmpty(motd.id)) {
+ String htmlFileId = cfg.getString(SECTION_MESSAGE, null, KEY_ID);
+ if (Strings.isNullOrEmpty(htmlFileId)) {
log.warn("id not defined, no message will be shown");
return Response.none();
}
@@ -95,14 +95,15 @@
}
try {
- motd.html = new String(Files.readAllBytes(dataDirPath.resolve(motd.id + ".html")), UTF_8);
+ motd.html = new String(Files.readAllBytes(dataDirPath.resolve(htmlFileId + ".html")), UTF_8);
} catch (IOException e1) {
log.warn(
String.format(
- "No HTML-file was found for message %s, no message will be shown", motd.id));
+ "No HTML-file was found for message %s, no message will be shown", htmlFileId));
return Response.none();
}
+ motd.id = Integer.toString(motd.html.hashCode());
return Response.ok(motd);
}
}
diff --git a/src/main/resources/Documentation/about.md b/src/main/resources/Documentation/about.md
index 26cc63d..46e0ca9 100644
--- a/src/main/resources/Documentation/about.md
+++ b/src/main/resources/Documentation/about.md
@@ -3,6 +3,7 @@
The plugin makes use of Gerrit's MessageOfTheDay extension point.
The plugin will display the configured message at the top of the screen.
-The user can dismiss the message banner. Upon dismissal, the banner will be
-redisplayed on the web UI the next day at 00:00. (The next day is calculated
-with respect to the client)
+The user can dismiss the message banner. Upon dismissal, the banner will
+be redisplayed on the web UI the next day at 00:00. The next day is
+calculated with respect to the client. Note that, after dismissal, the
+banner will be redisplayed (before the next day) if its message is updated.
diff --git a/src/main/resources/Documentation/rest-api-config.md b/src/main/resources/Documentation/rest-api-config.md
index 84ed041..d13d089 100644
--- a/src/main/resources/Documentation/rest-api-config.md
+++ b/src/main/resources/Documentation/rest-api-config.md
@@ -44,7 +44,7 @@
The `MessageOfTheDayInfo` entity contains information about the message of the day.
-* `id`: ID of the message.
+* `id`: ID of the message generated based on the message content.
* `starts_at`: Date, when the message will be first displayed
* `expires_at`: Date, after which the message will not be displayed anymore
* `html`: String, containing the HTML-formatted message