did stick/unstick, freeze/unfreeze, and archive/unarchive topic for three quick wins

This commit is contained in:
2026-01-29 11:36:03 -07:00
parent 3a9542e927
commit a18a7c70f7
6 changed files with 122 additions and 8 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Amsterdam Web Communities System
* Copyright (c) 2025 Erbosoft Metaverse Design Solutions, All Rights Reserved
* 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
@@ -66,7 +66,7 @@ const (
AuditConferenceMembership = 305
AuditConferenceCreateTopic = 306
AuditConferenceDeleteTopic = 307
AudotConferenceFreezeTopic = 308
AuditConferenceFreezeTopic = 308
AuditConferenceArchiveTopic = 309
AuditConferencePostMessage = 310
AuditConferenceHideMessage = 311
+42
View File
@@ -129,6 +129,48 @@ func (t *Topic) SetHidden(ctx context.Context, u *User, hidden bool) error {
return err
}
// SetFrozen sets a topic's "frozen" state.
func (t *Topic) SetFrozen(ctx context.Context, frozen bool, u *User, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
}()
_, err := amdb.ExecContext(ctx, "UPDATE topics SET frozen = ? WHERE topicid = ?", frozen, t.TopicId)
if err == nil {
t.Frozen = frozen
ar = AmNewAudit(AuditConferenceFreezeTopic, u.Uid, ipaddr, fmt.Sprintf("topic=%d", t.TopicId), fmt.Sprintf("frozen=%t", frozen))
}
return err
}
// SetArchived sets a topic's "archived" state.
func (t *Topic) SetArchived(ctx context.Context, archived bool, u *User, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
}()
_, err := amdb.ExecContext(ctx, "UPDATE topics SET archived = ? WHERE topicid = ?", archived, t.TopicId)
if err == nil {
t.Archived = archived
ar = AmNewAudit(AuditConferenceArchiveTopic, u.Uid, ipaddr, fmt.Sprintf("topic=%d", t.TopicId), fmt.Sprintf("archived=%t", archived))
}
return err
}
// SetSticky sets a topic's "sticky" state.
func (t *Topic) SetSticky(ctx context.Context, sticky bool, u *User, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
}()
_, err := amdb.ExecContext(ctx, "UPDATE topics SET sticky = ? where topicid = ?", sticky, t.TopicId)
if err == nil {
t.Sticky = sticky
ar = AmNewAudit(AuditConferenceStickyTopic, u.Uid, ipaddr, fmt.Sprintf("topic=%d", t.TopicId), fmt.Sprintf("sticky=%t", sticky))
}
return err
}
// IsBozo returns true if the specified test UID is filtered for the specified user.
func (t *Topic) IsBozo(ctx context.Context, u *User, testUid int32) (bool, error) {
if u.IsAnon {