From 8341a6e4d41a33b80b95b86b2a6c71f34cfd7c19 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Thu, 29 Jan 2026 18:16:23 -0700 Subject: [PATCH] created the "move message" page --- conference.go | 1 + conference_ops.go | 50 +++++++++++++++++++++++++++++++++++++++ main.go | 1 + ui/views/move_message.jet | 46 +++++++++++++++++++++++++++++++++++ ui/views/posts.jet | 4 ++-- 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 ui/views/move_message.jet diff --git a/conference.go b/conference.go index 6202892..49ba42b 100644 --- a/conference.go +++ b/conference.go @@ -570,6 +570,7 @@ func ReadPosts(ctxt ui.AmContext) (string, any, error) { canScribble := !isScribbled && (isMyPost || confNukePerm) ctxt.VarMap().Set("canScribble", canScribble) ctxt.VarMap().Set("canNuke", confNukePerm) + ctxt.VarMap().Set("canMove", confNukePerm && conf.TestPermission("Conference.Post", myLevel) && topic.TopMessage > 0) canPublish := !isScribbled && database.AmTestPermission("Global.PublishFP", myLevel) if canPublish { published, _ := posts[0].IsPublished(ctxt.Ctx()) diff --git a/conference_ops.go b/conference_ops.go index 94d71b8..5da201e 100644 --- a/conference_ops.go +++ b/conference_ops.go @@ -406,6 +406,56 @@ func NukeMessage(ctxt ui.AmContext) (string, any, error) { return mbox.Render(ctxt) } +func MoveMessageForm(ctxt ui.AmContext) (string, any, error) { + if ctxt.CurrentUser().IsAnon { + ctxt.SetRC(http.StatusForbidden) + return ui.ErrorPage(ctxt, ENOPERM) + } + conf := ctxt.GetScratch("currentConference").(*database.Conference) + myLevel := ctxt.GetScratch("levelInConference").(uint16) + topic := ctxt.GetScratch("currentTopic").(*database.Topic) + msgNum, err := strconv.Atoi(ctxt.URLParam("msg")) + if err != nil { + return ui.ErrorPage(ctxt, err) + } + hdrs, err := database.AmGetPostRange(ctxt.Ctx(), topic, int32(msgNum), int32(msgNum)) + if err != nil { + return ui.ErrorPage(ctxt, err) + } else if len(hdrs) != 1 { + return ui.ErrorPage(ctxt, errors.New("internal error getting post reference")) + } + if !conf.TestPermission("Conference.Nuke", myLevel) || !conf.TestPermission("Conference.Post", myLevel) || topic.TopMessage == 0 { + ctxt.SetRC(http.StatusForbidden) + return ui.ErrorPage(ctxt, ENOPERM) + } + + creator, err := hdrs[0].Creator(ctxt.Ctx()) + if err != nil { + return ui.ErrorPage(ctxt, err) + } + ctxt.VarMap().Set("creator", creator) + + topiclist, err := database.AmListTopics(ctxt.Ctx(), conf.ConfId, ctxt.CurrentUserId(), database.TopicViewAll, database.TopicSortName, true) + if err != nil { + return ui.ErrorPage(ctxt, err) + } + for i := range topiclist { + if topiclist[i].TopicID == topic.TopicId { + topiclist = append(topiclist[:i], topiclist[i+1:]...) + break + } + } + ctxt.VarMap().Set("topiclist", topiclist) + + ctxt.VarMap().Set("post", hdrs[0]) + ctxt.VarMap().Set("topMessage", topic.TopMessage) + formLink := fmt.Sprintf("/comm/%s/conf/%s/op/%d/move/%d", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num) + ctxt.VarMap().Set("formLink", formLink) + ctxt.VarMap().Set("amsterdam_pageTitle", "Move Message") + + return "framed_template", "move_message.jet", nil +} + /* TopicManage displays the "manage topic" page. * Parameters: * ctxt - The AmContext for the request. diff --git a/main.go b/main.go index 9004eec..28bfd11 100644 --- a/main.go +++ b/main.go @@ -113,6 +113,7 @@ func setupEcho() *echo.Echo { opsGroup.GET("/hide/:msg", ui.AmWrap(HideMessage)) opsGroup.GET("/scribble/:msg", ui.AmWrap(ScribbleMessage)) opsGroup.GET("/nuke/:msg", ui.AmWrap(NukeMessage)) + opsGroup.GET("/move/:msg", ui.AmWrap(MoveMessageForm)) opsGroup.GET("/manage", ui.AmWrap(TopicManage)) opsGroup.GET("/subscribe", ui.AmWrap(TopicSetSubscribe)) opsGroup.GET("/rmbozo/:uid", ui.AmWrap(TopicRemoveBozo)) diff --git a/ui/views/move_message.jet b/ui/views/move_message.jet new file mode 100644 index 0000000..beeb93a --- /dev/null +++ b/ui/views/move_message.jet @@ -0,0 +1,46 @@ +{* + * Amsterdam Web Communities System + * Copyright (c) 2025-2026 Erbosoft Metaverse Design Solutions, All Rights Reserved + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + *} +
+ +
+

Move Message

+
+
+ + +
+ Message {{ post.Num }} of {{ topMessage }}: {{ if post.Hidden }}(Hidden){{ end }} +
+
+ {{ post.Pseud | raw }} ({{ creator.Username }}, {{ DisplayDateTime(post.Posted, .) }}) +
+ + +
+
+ + +
+
+ + +
+
+
diff --git a/ui/views/posts.jet b/ui/views/posts.jet index cad95cd..a0f185a 100644 --- a/ui/views/posts.jet +++ b/ui/views/posts.jet @@ -139,8 +139,8 @@ Nuke {{ end }} - {{ if false }}{* TODO *} - Move {{ end }} {{ if canPublish }}