From 4dd15aa0d25ca88ed41214c5e94536c717e1dba9 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Wed, 28 Jan 2026 15:40:13 -0700 Subject: [PATCH] hooled up "scribble message" --- conference.go | 2 ++ conference_ops.go | 37 +++++++++++++++++++++++++++++++++++++ docs/MISSINGFUNCS.md | 2 +- main.go | 1 + ui/views/posts.jet | 2 +- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/conference.go b/conference.go index c675ab5..dac1910 100644 --- a/conference.go +++ b/conference.go @@ -115,6 +115,8 @@ func Topics(ctxt ui.AmContext) (string, any, error) { if firstTopic >= 1 { ctxt.VarMap().Set("urlReadNew", fmt.Sprintf("%s/r/%d", urlStem, firstTopic)) } + } else { + ctxt.SetSession("topic.traverser", nil) } tz := prefs.Location() diff --git a/conference_ops.go b/conference_ops.go index 8f8a7fb..1633a69 100644 --- a/conference_ops.go +++ b/conference_ops.go @@ -239,6 +239,43 @@ func HideMessage(ctxt ui.AmContext) (string, any, error) { return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num), nil } +/* ScribbleMessage scribbles a topic message. + * Parameters: + * ctxt - The AmContext for the request. + * Returns: + * Command string dictating what to be rendered. + * Data as a parameter for the command string. + * Standard Go error status. + */ +func ScribbleMessage(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 (hdrs[0].CreatorUid != ctxt.CurrentUserId()) && !conf.TestPermission("Conference.Nuke", myLevel) { + ctxt.SetRC(http.StatusForbidden) + return ui.ErrorPage(ctxt, ENOPERM) + } + err = hdrs[0].Scribble(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.RemoteIP()) + if err != nil { + return ui.ErrorPage(ctxt, err) + } + return "redirect", fmt.Sprintf("/comm/%s/conf/%s/r/%d?r=%d&ac=1", ctxt.CurrentCommunity().Alias, ctxt.GetScratch("currentAlias"), topic.Number, hdrs[0].Num), nil +} + /* TopicManage displays the "manage topic" page. * Parameters: * ctxt - The AmContext for the request. diff --git a/docs/MISSINGFUNCS.md b/docs/MISSINGFUNCS.md index 7cd0486..d8878d4 100644 --- a/docs/MISSINGFUNCS.md +++ b/docs/MISSINGFUNCS.md @@ -40,7 +40,7 @@ _(italicized items can be deferred)_ - Freeze/Unfreeze - Archive/Unarchive - Delete - - Post Scribble + - ~~Post Scribble~~ - Post Nuke - Post Filter User - Post Move diff --git a/main.go b/main.go index 2c8af31..796c850 100644 --- a/main.go +++ b/main.go @@ -108,6 +108,7 @@ func setupEcho() *echo.Echo { opsGroup := confGroup.Group("/op/:topic", ui.SetTopic) opsGroup.GET("/hide", ui.AmWrap(HideTopic)) opsGroup.GET("/hide/:msg", ui.AmWrap(HideMessage)) + opsGroup.GET("/scribble/:msg", ui.AmWrap(ScribbleMessage)) opsGroup.GET("/manage", ui.AmWrap(TopicManage)) return e diff --git a/ui/views/posts.jet b/ui/views/posts.jet index c0a980d..2600b1f 100644 --- a/ui/views/posts.jet +++ b/ui/views/posts.jet @@ -126,7 +126,7 @@ {{ end }} {{ if canScribble }} - Scribble {{ end }} {{ if false }}{* TODO *}