diff --git a/pkg/chat/chat_api.go b/pkg/chat/chat_api.go index 8b18bf2..55dc742 100644 --- a/pkg/chat/chat_api.go +++ b/pkg/chat/chat_api.go @@ -163,14 +163,14 @@ func DisconnectUserNow(user *models.User, message string) (int, error) { } // EraseChatHistory tells the chat room to clear DMs history for this user. -func EraseChatHistory(user *models.User) (int, error) { +func EraseChatHistory(username string) (int, error) { // API request struct for BareRTC /api/message/clear endpoint. var request = struct { APIKey string Username string }{ APIKey: config.Current.CronAPIKey, - Username: user.Username, + Username: username, } type response struct { diff --git a/pkg/controller/account/settings.go b/pkg/controller/account/settings.go index 34a64a3..187a375 100644 --- a/pkg/controller/account/settings.go +++ b/pkg/controller/account/settings.go @@ -339,6 +339,18 @@ func Settings() http.HandlerFunc { return } + // Clear their history on the chat room. + go func(username string) { + log.Error("Change of username, clear chat history for old name %s", username) + i, err := chat.EraseChatHistory(username) + if err != nil { + log.Error("EraseChatHistory(%s): %s", username, err) + return + } + + session.Flash(w, r, "Notice: due to your recent change in username, your direct message history on the Chat Room has been reset. %d message(s) had been removed.", i) + }(user.Username) + // Set their name. origUsername := user.Username user.Username = changeUsername diff --git a/pkg/controller/photo/edit_delete.go b/pkg/controller/photo/edit_delete.go index 01816b2..f44a56a 100644 --- a/pkg/controller/photo/edit_delete.go +++ b/pkg/controller/photo/edit_delete.go @@ -238,6 +238,13 @@ func Delete() http.HandlerFunc { } } + // Inner circle warning: if this deletion would drop them below the 5 public picture + // threshold, warn them they will be removed from the circle if they continue. + var innerCircleWarning bool + if currentUser.IsInnerCircle() && photo.Visibility == models.PhotoPublic && models.CountPublicPhotos(currentUser.ID) <= 5 { + innerCircleWarning = true + } + // Confirm deletion? if r.Method == http.MethodPost { confirm := r.PostFormValue("confirm") == "true" @@ -281,6 +288,15 @@ func Delete() http.HandlerFunc { // Log the change. models.LogDeleted(currentUser, requestUser, "photos", photo.ID, "Deleted the photo.", photo) + // Remove them from the inner circle? + if innerCircleWarning { + if err := models.RemoveFromInnerCircle(currentUser); err != nil { + session.FlashError(w, r, "Couldn't remove from the inner circle: %s", err) + } else { + session.Flash(w, r, "You have been removed from the inner circle because your count of public photos has dropped below 5.") + } + } + session.Flash(w, r, "Photo deleted!") // Maybe kick them from chat if this deletion makes them into a Shy Account. @@ -294,7 +310,8 @@ func Delete() http.HandlerFunc { } var vars = map[string]interface{}{ - "Photo": photo, + "Photo": photo, + "InnerCircleWarning": innerCircleWarning, } if err := tmpl.Execute(w, r, vars); err != nil { diff --git a/pkg/models/deletion/delete_user.go b/pkg/models/deletion/delete_user.go index 58d9f0a..1654624 100644 --- a/pkg/models/deletion/delete_user.go +++ b/pkg/models/deletion/delete_user.go @@ -15,7 +15,7 @@ func DeleteUser(user *models.User) error { // Clear their history on the chat room. go func() { - i, err := chat.EraseChatHistory(user) + i, err := chat.EraseChatHistory(user.Username) if err != nil { log.Error("EraseChatHistory(%s): %s", user.Username, err) return diff --git a/web/static/css/dark-theme.css b/web/static/css/dark-theme.css index 907b951..6bec6fd 100644 --- a/web/static/css/dark-theme.css +++ b/web/static/css/dark-theme.css @@ -14,7 +14,11 @@ } .has-background-warning-light, .has-background-warning { - background-color: rgb(100, 90, 41) !important; + background-color: rgb(44, 40, 18) !important; +} + +.has-background-danger-light, .has-background-danger { + background-color: rgb(31, 13, 13) !important; } .has-background-link-light { diff --git a/web/templates/photo/delete.html b/web/templates/photo/delete.html index 6c0b8b6..3f1c407 100644 --- a/web/templates/photo/delete.html +++ b/web/templates/photo/delete.html @@ -40,6 +40,30 @@
Are you sure you want to delete this photo?
+ {{if .InnerCircleWarning}} +
+ + + Important + {{PrettyCircle}} + Inner circle icon + Information + + +
+ When you delete this photo, your count of public photos will drop below 5 (five) + and you will be immediately removed from the inner circle. +
+ +
+ If you wish to avoid this, please upload a new public photo + before deleting this one. {{PrettyCircle}} members are expected to maintain at + least 5 nudes with face on their public gallery — it's what qualified you + to be invited to the inner circle in the first place! + Learn more +
+
+ {{end}}