created the "move message" page

This commit is contained in:
2026-01-29 18:16:23 -07:00
parent 8a66579c31
commit 8341a6e4d4
5 changed files with 100 additions and 2 deletions
+1
View File
@@ -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())
+50
View File
@@ -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.
+1
View File
@@ -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))
+46
View File
@@ -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/.
*}
<div class="p-4">
<!-- Top Title -->
<div class="mb-2">
<h1 class="text-blue-800 text-4xl font-bold inline">Move Message</h1>
<hr class="border-2 border-gray-400 w-4/5 mt-2 mb-2">
</div>
<!-- Post Identifier -->
<div class="mb-2">
Message {{ post.Num }} of {{ topMessage }}: {{ if post.Hidden }}<b><em>(Hidden)</em></b>{{ end }}
</div>
<div class="mb-6">
<b>{{ post.Pseud | raw }}</b> (<em><a href="/user/{{ creator.Username }}">{{ creator.Username }}</a>, {{ DisplayDateTime(post.Posted, .) }}</em>)
</div>
<!-- Topic Selection Form -->
<form method="POST" action="{{ formLink }}">
<div class="bg-gray-50 p-6 rounded-lg space-y-4">
<label for="target" class="block text-black text-sm font-bold mb-2">Move to topic:</label>
<select id="target" name="target" size="1"
class="flex-1 px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
{{ range i, t := topiclist }}
<option value="{{ t.TopicID }}">{{ t.Name | raw }}</option>
{{ end }}
</select>
</div>
<div class="flex justify-center gap-4 pt-4">
<button type="submit" name="move"
class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded font-medium transition-colors">
Move
</button>
<button type="submit" name="cancel"
class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded font-medium transition-colors">
Cancel
</button>
</div>
</form>
</div>
+2 -2
View File
@@ -139,8 +139,8 @@
<a href="{{ topicListLink }}/op/{{ topicNum }}/nuke/{{ p.Num }}"
class="bg-red-600 hover:bg-red-700 text-white px-3 py-2 rounded text-sm font-medium transition-colors whitespace-nowrap">Nuke</a>
{{ end }}
{{ if false }}{* TODO *}
<a href="/TODO"
{{ if canMove }}
<a href="{{ topicListLink }}/op/{{ topicNum }}/move/{{ p.Num }}"
class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded text-sm font-medium transition-colors whitespace-nowrap">Move</a>
{{ end }}
{{ if canPublish }}