diff --git a/internal/webserver/handler_messages.go b/internal/webserver/handler_messages.go
index 5d5d548..aef3cbf 100644
--- a/internal/webserver/handler_messages.go
+++ b/internal/webserver/handler_messages.go
@@ -29,7 +29,10 @@ func (t MessageData) FocusedTweetID() scraper.TweetID {
func (app *Application) Messages(w http.ResponseWriter, r *http.Request) {
app.traceLog.Printf("'Messages' handler (path: %q)", r.URL.Path)
- // TODO: what if no active user?
+ if app.ActiveUser.ID == 0 {
+ app.error_401(w)
+ return
+ }
chat_view := app.Profile.GetChatRoomsPreview(app.ActiveUser.ID)
if strings.Trim(r.URL.Path, "/") != "" {
diff --git a/internal/webserver/response_helpers.go b/internal/webserver/response_helpers.go
index 2c0b2a2..b0e6adb 100644
--- a/internal/webserver/response_helpers.go
+++ b/internal/webserver/response_helpers.go
@@ -61,6 +61,10 @@ func (app *Application) error_400_with_message(w http.ResponseWriter, msg string
http.Error(w, fmt.Sprintf("Bad Request\n\n%s", msg), 400)
}
+func (app *Application) error_401(w http.ResponseWriter) {
+ http.Error(w, "Please log in or set an active session", 401)
+}
+
func (app *Application) error_404(w http.ResponseWriter) {
http.Error(w, "Not Found", 404)
}
diff --git a/internal/webserver/tpl/includes/nav_sidebar.tpl b/internal/webserver/tpl/includes/nav_sidebar.tpl
index fcf1800..d35d1a4 100644
--- a/internal/webserver/tpl/includes/nav_sidebar.tpl
+++ b/internal/webserver/tpl/includes/nav_sidebar.tpl
@@ -25,12 +25,14 @@
Notifications
-
-
-
- Messages
-
-
+ {{if (not (eq (active_user).Handle "[nobody]"))}}
+
+
+
+ Messages
+
+
+ {{end}}