all audit messages that were implemented but needed community ID context now have it

This commit is contained in:
2026-02-21 17:25:40 -07:00
parent 236f63c37e
commit 5acb67106c
8 changed files with 54 additions and 55 deletions
+2 -2
View File
@@ -286,7 +286,7 @@ func NewTopic(ctxt ui.AmContext) (string, any) {
lines, _ := checker.Lines()
// Add the topic!
topic, err := database.AmNewTopic(ctxt.Ctx(), conf, ctxt.CurrentUser(), topicName, zeroPostPseud, zeroPost, int32(lines), ctxt.RemoteIP())
topic, err := database.AmNewTopic(ctxt.Ctx(), conf, ctxt.CurrentUser(), topicName, zeroPostPseud, zeroPost, int32(lines), comm, ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -780,7 +780,7 @@ func PostInTopic(ctxt ui.AmContext) (string, any) {
lines, _ := checker.Lines()
// Add the post!
hdr, err := database.AmNewPost(ctxt.Ctx(), conf, topic, ctxt.CurrentUser(), postPseud, postText, int32(lines), ctxt.RemoteIP())
hdr, err := database.AmNewPost(ctxt.Ctx(), conf, topic, ctxt.CurrentUser(), postPseud, postText, int32(lines), comm, ctxt.RemoteIP())
if err != nil {
return "error", err
}
+11 -10
View File
@@ -64,7 +64,8 @@ func AttachmentUpload(ctxt ui.AmContext) (string, any) {
var data []byte
data, err = slurpFile(file)
if err == nil {
err = post.SetAttachment(ctxt.Ctx(), ctxt.CurrentUser(), file.Filename, file.Header.Get("Content-Type"), int32(file.Size), data, ctxt.RemoteIP())
err = post.SetAttachment(ctxt.Ctx(), ctxt.CurrentUser(), file.Filename, file.Header.Get("Content-Type"), int32(file.Size),
data, ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err == nil {
return "redirect", target
}
@@ -268,7 +269,7 @@ func FreezeTopic(ctxt ui.AmContext) (string, any) {
if !conf.TestPermission("Conference.Hide", myLevel) {
return "error", ENOPERM
}
err := topic.SetFrozen(ctxt.Ctx(), !topic.Frozen, ctxt.CurrentUser(), ctxt.RemoteIP())
err := topic.SetFrozen(ctxt.Ctx(), !topic.Frozen, ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -289,7 +290,7 @@ func ArchiveTopic(ctxt ui.AmContext) (string, any) {
if !conf.TestPermission("Conference.Hide", myLevel) {
return "error", ENOPERM
}
err := topic.SetArchived(ctxt.Ctx(), !topic.Archived, ctxt.CurrentUser(), ctxt.RemoteIP())
err := topic.SetArchived(ctxt.Ctx(), !topic.Archived, ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -310,7 +311,7 @@ func StickTopic(ctxt ui.AmContext) (string, any) {
if !conf.TestPermission("Conference.Hide", myLevel) {
return "error", ENOPERM
}
err := topic.SetSticky(ctxt.Ctx(), !topic.Sticky, ctxt.CurrentUser(), ctxt.RemoteIP())
err := topic.SetSticky(ctxt.Ctx(), !topic.Sticky, ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -341,7 +342,7 @@ func DeleteTopic(ctxt ui.AmContext) (string, any) {
return "error", err
}
if mbox.Validate(ctxt, "yes") {
err := topic.Delete(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.RemoteIP(), ampool)
err := topic.Delete(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP(), ampool)
if err != nil {
return "error", err
}
@@ -383,7 +384,7 @@ func HideMessage(ctxt ui.AmContext) (string, any) {
if (hdrs[0].CreatorUid != ctxt.CurrentUserId()) && !conf.TestPermission("Conference.Hide", myLevel) {
return "error", ENOPERM
}
err = hdrs[0].SetHidden(ctxt.Ctx(), ctxt.CurrentUser(), !(hdrs[0].Hidden), ctxt.RemoteIP())
err = hdrs[0].SetHidden(ctxt.Ctx(), ctxt.CurrentUser(), !(hdrs[0].Hidden), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -417,7 +418,7 @@ func ScribbleMessage(ctxt ui.AmContext) (string, any) {
if (hdrs[0].CreatorUid != ctxt.CurrentUserId()) && !conf.TestPermission("Conference.Nuke", myLevel) {
return "error", ENOPERM
}
err = hdrs[0].Scribble(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.RemoteIP())
err = hdrs[0].Scribble(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -459,7 +460,7 @@ func NukeMessage(ctxt ui.AmContext) (string, any) {
}
if mbox.Validate(ctxt, "yes") {
// do the nuking!
err := hdrs[0].Nuke(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.RemoteIP())
err := hdrs[0].Nuke(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -517,7 +518,7 @@ func PruneMessageAttachment(ctxt ui.AmContext) (string, any) {
}
if mbox.Validate(ctxt, "yes") {
// do the pruning!
err := hdrs[0].PruneAttachment(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.RemoteIP())
err := hdrs[0].PruneAttachment(ctxt.Ctx(), ctxt.CurrentUser(), ctxt.CurrentCommunity(), ctxt.RemoteIP())
if err != nil {
return "error", err
}
@@ -666,7 +667,7 @@ func MoveMessage(ctxt ui.AmContext) (string, any) {
}
// Move the topic!
err = hdrs[0].MoveTo(ctxt.Ctx(), target, ctxt.CurrentUser(), ctxt.RemoteIP())
err = hdrs[0].MoveTo(ctxt.Ctx(), target, ctxt.CurrentUser(), comm, ctxt.RemoteIP())
if err != nil {
return "error", err
}
+3 -3
View File
@@ -151,7 +151,7 @@ func ConferenceAliasForm(ctxt ui.AmContext) (string, any) {
ctxt.SetFrameTitle(fmt.Sprintf("Manage Conference Aliases: %s", conf.Name))
if ctxt.HasParameter("del") {
err := conf.RemoveAlias(ctxt.Ctx(), ctxt.Parameter("del"), ctxt.CurrentUser(), ctxt.RemoteIP())
err := conf.RemoveAlias(ctxt.Ctx(), ctxt.Parameter("del"), ctxt.CurrentUser(), comm, ctxt.RemoteIP())
if err != nil {
ctxt.VarMap().Set("errorMessage", err.Error())
}
@@ -192,7 +192,7 @@ func ConferenceAliasAdd(ctxt ui.AmContext) (string, any) {
var err error = nil
if ctxt.FormFieldIsSet("add") {
if database.AmIsValidAmsterdamID(newAlias) {
err = conf.AddAlias(ctxt.Ctx(), newAlias, ctxt.CurrentUser(), ctxt.RemoteIP())
err = conf.AddAlias(ctxt.Ctx(), newAlias, ctxt.CurrentUser(), comm, ctxt.RemoteIP())
} else {
err = fmt.Errorf("value '%s' is not a valid Amsterdam id", newAlias)
}
@@ -300,7 +300,7 @@ func ConferenceMembers(ctxt ui.AmContext) (string, any) {
var u *database.User
u, err = database.AmGetUser(ctxt.Ctx(), uid)
if err == nil {
err = conf.SetMembership(ctxt.Ctx(), u, newLevel, ctxt.CurrentUser(), ctxt.RemoteIP())
err = conf.SetMembership(ctxt.Ctx(), u, newLevel, ctxt.CurrentUser(), comm, ctxt.RemoteIP())
}
}
}
+1 -1
View File
@@ -91,7 +91,7 @@ const (
AuditAdminLockUnlockAccount = 113
AuditCommunityCreate = 201
AuditCommunitySetMembership = 202
AuditCommuntiyContactInfo = 203
AuditCommunityContactInfo = 203
AuditCommunityFeatureSet = 204
AuditCommunityName = 205
AuditCommunityAlias = 206
+3 -4
View File
@@ -383,9 +383,8 @@ func (c *Community) SetMembership(ctx context.Context, u *User, level uint16, lo
}
}
if err := c.TouchUpdateTx(ctx, tx); err == nil {
ar := AmNewAudit(AuditCommunitySetMembership, personUID, ipaddr, fmt.Sprintf("cid=%d", c.Id),
fmt.Sprintf("uid=%d", u.Uid), fmt.Sprintf("level=%d", level))
AmStoreAudit(ar)
AmStoreAudit(AmNewCommAudit(AuditCommunitySetMembership, personUID, c.Id, ipaddr, fmt.Sprintf("cid=%d", c.Id),
fmt.Sprintf("uid=%d", u.Uid), fmt.Sprintf("level=%d", level)))
}
return nil
}
@@ -918,7 +917,7 @@ func AmCreateCommunity(ctx context.Context, name string, alias string, hostUid i
success = true
// operation was a success - add an audit record
ar = AmNewAudit(AuditCommunityCreate, hostUid, remoteIP, fmt.Sprintf("id=%d", comm.Id),
ar = AmNewCommAudit(AuditCommunityCreate, hostUid, comm.Id, remoteIP, fmt.Sprintf("id=%d", comm.Id),
fmt.Sprintf("name=%s", comm.Name), fmt.Sprintf("alias=%s", comm.Alias))
return comm, nil
}
+9 -11
View File
@@ -171,7 +171,7 @@ func (c *Conference) AliasesQ(ctx context.Context) []string {
}
// AddAlias adds an alias to the conference.
func (c *Conference) AddAlias(ctx context.Context, alias string, u *User, ipaddr string) error {
func (c *Conference) AddAlias(ctx context.Context, alias string, u *User, comm *Community, ipaddr string) error {
row := amdb.QueryRowContext(ctx, "SELECT alias FROM confalias WHERE confid = ? AND alias = ?", c.ConfId, alias)
tmp := ""
err := row.Scan(&tmp)
@@ -186,13 +186,12 @@ func (c *Conference) AddAlias(ctx context.Context, alias string, u *User, ipaddr
return err
}
ar := AmNewAudit(AuditConferenceAlias, u.Uid, ipaddr, fmt.Sprintf("conf=%d", c.ConfId), fmt.Sprintf("add=%s", alias))
AmStoreAudit(ar)
AmStoreAudit(AmNewCommAudit(AuditConferenceAlias, u.Uid, comm.Id, ipaddr, fmt.Sprintf("conf=%d", c.ConfId), fmt.Sprintf("add=%s", alias)))
return nil
}
// RemoveAlias removes an alias from the conference.
func (c *Conference) RemoveAlias(ctx context.Context, alias string, u *User, ipaddr string) error {
func (c *Conference) RemoveAlias(ctx context.Context, alias string, u *User, comm *Community, ipaddr string) error {
row := amdb.QueryRowContext(ctx, "SELECT COUNT(*) FROM confalias WHERE confid = ?", c.ConfId)
aliasCount := 0
err := row.Scan(&aliasCount)
@@ -223,8 +222,7 @@ func (c *Conference) RemoveAlias(ctx context.Context, alias string, u *User, ipa
return errors.New("alias not found")
}
ar := AmNewAudit(AuditConferenceAlias, u.Uid, ipaddr, fmt.Sprintf("conf=%d", c.ConfId), fmt.Sprintf("remove=%s", alias))
AmStoreAudit(ar)
AmStoreAudit(AmNewCommAudit(AuditConferenceAlias, u.Uid, comm.Id, ipaddr, fmt.Sprintf("conf=%d", c.ConfId), fmt.Sprintf("remove=%s", alias)))
return nil
}
@@ -332,7 +330,7 @@ func (c *Conference) Membership(ctx context.Context, u *User) (bool, uint16, err
}
// SetMembership sets the membership level for the given user in this conference.
func (c *Conference) SetMembership(ctx context.Context, u *User, level uint16, by *User, ipaddr string) error {
func (c *Conference) SetMembership(ctx context.Context, u *User, level uint16, by *User, comm *Community, ipaddr string) error {
if level == 0 {
_, err := amdb.ExecContext(ctx, "DELETE FROM confmember WHERE confid = ? AND uid = ?", c.ConfId, u.Uid)
return err
@@ -350,8 +348,8 @@ func (c *Conference) SetMembership(ctx context.Context, u *User, level uint16, b
_, err = amdb.ExecContext(ctx, "INSERT INTO confmember (confid, uid, granted_lvl) VALUES (?, ?, ?)", c.ConfId, u.Uid, level)
}
if err != nil {
ar := AmNewAudit(AuditConferenceMembership, by.Uid, ipaddr, fmt.Sprintf("conf=%d", c.ConfId), fmt.Sprintf("uid=%d", u.Uid), fmt.Sprintf("level=%d", level))
AmStoreAudit(ar)
AmStoreAudit(AmNewCommAudit(AuditConferenceMembership, by.Uid, comm.Id, ipaddr, fmt.Sprintf("conf=%d", c.ConfId),
fmt.Sprintf("uid=%d", u.Uid), fmt.Sprintf("level=%d", level)))
}
return err
}
@@ -916,7 +914,7 @@ func (c *Conference) Delete(ctx context.Context, comm *Community, u *User, ipadd
conferenceCache.Remove(c.ConfId)
// add an audit record
AmStoreAudit(AmNewAudit(AuditConferenceDelete, u.Uid, ipaddr, fmt.Sprintf("confid=%d", c.ConfId)))
AmStoreAudit(AmNewCommAudit(AuditConferenceDelete, u.Uid, comm.Id, ipaddr, fmt.Sprintf("confid=%d", c.ConfId)))
// set up a background job to purge the rest of the data
confid := c.ConfId
@@ -1292,6 +1290,6 @@ func AmCreateConference(ctx context.Context, comm *Community, name, alias, descr
// Add the new conference to the cache, and create our audit record.
conferenceCache.Add(rc[0].ConfId, &(rc[0]))
ar = AmNewAudit(AuditConferenceCreate, u.Uid, ipaddr, fmt.Sprintf("confid=%d", rc[0].ConfId), fmt.Sprintf("name=%s", name), fmt.Sprintf("alias=%s", alias))
ar = AmNewCommAudit(AuditConferenceCreate, u.Uid, comm.Id, ipaddr, fmt.Sprintf("confid=%d", rc[0].ConfId), fmt.Sprintf("name=%s", name), fmt.Sprintf("alias=%s", alias))
return &(rc[0]), nil
}
+15 -14
View File
@@ -163,7 +163,7 @@ func (p *PostHeader) AttachmentData(ctx context.Context, bugWorkaround bool) ([]
* Returns:
* Standard Go error status.
*/
func (p *PostHeader) SetAttachment(ctx context.Context, u *User, fileName string, mimeType string, length int32, data []byte, ipaddr string) error {
func (p *PostHeader) SetAttachment(ctx context.Context, u *User, fileName string, mimeType string, length int32, data []byte, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -209,7 +209,7 @@ func (p *PostHeader) SetAttachment(ctx context.Context, u *User, fileName string
_, err = amdb.ExecContext(ctx, "INSERT INTO postattach (postid, datalen, filename, mimetype, stgmethod, data) VALUES (?, ?, ?, ?, ?, ?)",
p.PostId, length, fileName, mimeType, stgmethod, realData)
// Generate an audit record.
ar = AmNewAudit(AuditConferenceUploadAttachment, u.Uid, ipaddr, fmt.Sprintf("post=%d", p.PostId),
ar = AmNewCommAudit(AuditConferenceUploadAttachment, u.Uid, comm.Id, ipaddr, fmt.Sprintf("post=%d", p.PostId),
fmt.Sprintf("len=%d,type=%s,name=%s,method=%d", length, mimeType, fileName, stgmethod))
return err
}
@@ -224,7 +224,7 @@ func (p *PostHeader) HitAttachment(ctx context.Context) error {
}
// PruneAttachment prunes (removes and deletes) the attachment of this post.
func (p *PostHeader) PruneAttachment(ctx context.Context, u *User, ipaddr string) error {
func (p *PostHeader) PruneAttachment(ctx context.Context, u *User, comm *Community, ipaddr string) error {
if p.ScribbleDate != nil && p.ScribbleUid != nil {
return errors.New("no attachment on scribbled post")
}
@@ -232,7 +232,7 @@ func (p *PostHeader) PruneAttachment(ctx context.Context, u *User, ipaddr string
if err == nil {
rowCount, err := rs.RowsAffected()
if err == nil && rowCount > 1 {
AmStoreAudit(AmNewAudit(AuditConferencePruneAttachment, u.Uid, ipaddr, fmt.Sprintf("post=%d", p.PostId)))
AmStoreAudit(AmNewCommAudit(AuditConferencePruneAttachment, u.Uid, comm.Id, ipaddr, fmt.Sprintf("post=%d", p.PostId)))
}
}
return err
@@ -277,7 +277,7 @@ func (p *PostHeader) Link(ctx context.Context, scope string) (string, error) {
}
// SetHidden sets the "hidden" flag on a post.
func (p *PostHeader) SetHidden(ctx context.Context, u *User, flag bool, ipaddr string) error {
func (p *PostHeader) SetHidden(ctx context.Context, u *User, flag bool, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -291,13 +291,13 @@ func (p *PostHeader) SetHidden(ctx context.Context, u *User, flag bool, ipaddr s
_, err := amdb.ExecContext(ctx, "UPDATE posts SET hidden = ? WHERE postid = ?", flag, p.PostId)
if err == nil {
p.Hidden = flag
ar = AmNewAudit(AuditConferenceHideMessage, u.Uid, ipaddr, fmt.Sprintf("post=%d", p.PostId), fmt.Sprintf("hidden=%t", flag))
ar = AmNewCommAudit(AuditConferenceHideMessage, u.Uid, comm.Id, ipaddr, fmt.Sprintf("post=%d", p.PostId), fmt.Sprintf("hidden=%t", flag))
}
return err
}
// Scribble causes a post to be scribbled.
func (p *PostHeader) Scribble(ctx context.Context, u *User, ipaddr string) error {
func (p *PostHeader) Scribble(ctx context.Context, u *User, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -354,12 +354,12 @@ func (p *PostHeader) Scribble(ctx context.Context, u *User, ipaddr string) error
p.Pseud = &scribblePseud
// Audit the operation.
ar = AmNewAudit(AuditConferenceScribbleMessage, u.Uid, ipaddr, fmt.Sprintf("post=%d", p.PostId))
ar = AmNewCommAudit(AuditConferenceScribbleMessage, u.Uid, comm.Id, ipaddr, fmt.Sprintf("post=%d", p.PostId))
return nil
}
// Nuke causes a post to be nuked (deleted entirely from the topic).
func (p *PostHeader) Nuke(ctx context.Context, u *User, ipaddr string) error {
func (p *PostHeader) Nuke(ctx context.Context, u *User, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -414,7 +414,7 @@ func (p *PostHeader) Nuke(ctx context.Context, u *User, ipaddr string) error {
return err
}
success = true
ar = AmNewAudit(AuditConferenceNukeMessage, u.Uid, ipaddr, fmt.Sprintf("post=%d", p.PostId))
ar = AmNewCommAudit(AuditConferenceNukeMessage, u.Uid, comm.Id, ipaddr, fmt.Sprintf("post=%d", p.PostId))
return nil
}
@@ -460,7 +460,7 @@ func (p *PostHeader) Publish(ctx context.Context, comm *Community, publisher *Us
}
// MoveTo moves this message to a new topic.
func (p *PostHeader) MoveTo(ctx context.Context, target *Topic, u *User, ipaddr string) error {
func (p *PostHeader) MoveTo(ctx context.Context, target *Topic, u *User, comm *Community, ipaddr string) error {
if target.TopicId == p.TopicId {
return nil // this is a no-op
}
@@ -548,7 +548,7 @@ func (p *PostHeader) MoveTo(ctx context.Context, target *Topic, u *User, ipaddr
target.LastUpdate = lastUpdate
// And audit the result.
ar = AmNewAudit(AuditConferenceMoveMessage, u.Uid, ipaddr, fmt.Sprintf("conf=%d,post=%d", conf.ConfId, p.PostId),
ar = AmNewCommAudit(AuditConferenceMoveMessage, u.Uid, comm.Id, ipaddr, fmt.Sprintf("conf=%d,post=%d", conf.ConfId, p.PostId),
fmt.Sprintf("fromTopic=%d", oldTopic.TopicId), fmt.Sprintf("toTopic=%d", target.TopicId))
return nil
}
@@ -611,7 +611,8 @@ func AmGetPostRange(ctx context.Context, topic *Topic, first, last int32) ([]*Po
* New post header pointer.
* Standard Go error status.
*/
func AmNewPost(ctx context.Context, conf *Conference, topic *Topic, user *User, pseud string, post string, postLines int32, ipaddr string) (*PostHeader, error) {
func AmNewPost(ctx context.Context, conf *Conference, topic *Topic, user *User, pseud string, post string, postLines int32,
comm *Community, ipaddr string) (*PostHeader, error) {
success := false
var ar *AuditRecord = nil
defer func() {
@@ -677,7 +678,7 @@ func AmNewPost(ctx context.Context, conf *Conference, topic *Topic, user *User,
success = true
// create audit record
ar = AmNewAudit(AuditConferencePostMessage, user.Uid, ipaddr, fmt.Sprintf("confid=%d", conf.ConfId),
ar = AmNewCommAudit(AuditConferencePostMessage, user.Uid, comm.Id, ipaddr, fmt.Sprintf("confid=%d", conf.ConfId),
fmt.Sprintf("topic=%d", topic.Number), fmt.Sprintf("post=%d", hdr.PostId), fmt.Sprintf("pseud=%s", *hdr.Pseud))
return hdr, nil
+10 -10
View File
@@ -131,7 +131,7 @@ func (t *Topic) SetHidden(ctx context.Context, u *User, hidden bool) error {
}
// SetFrozen sets a topic's "frozen" state.
func (t *Topic) SetFrozen(ctx context.Context, frozen bool, u *User, ipaddr string) error {
func (t *Topic) SetFrozen(ctx context.Context, frozen bool, u *User, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -139,13 +139,13 @@ func (t *Topic) SetFrozen(ctx context.Context, frozen bool, u *User, ipaddr stri
_, 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))
ar = AmNewCommAudit(AuditConferenceFreezeTopic, u.Uid, comm.Id, 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 {
func (t *Topic) SetArchived(ctx context.Context, archived bool, u *User, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -153,13 +153,13 @@ func (t *Topic) SetArchived(ctx context.Context, archived bool, u *User, ipaddr
_, 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))
ar = AmNewCommAudit(AuditConferenceArchiveTopic, u.Uid, comm.Id, 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 {
func (t *Topic) SetSticky(ctx context.Context, sticky bool, u *User, comm *Community, ipaddr string) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -167,7 +167,7 @@ func (t *Topic) SetSticky(ctx context.Context, sticky bool, u *User, ipaddr stri
_, 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))
ar = AmNewCommAudit(AuditConferenceStickyTopic, u.Uid, comm.Id, ipaddr, fmt.Sprintf("topic=%d", t.TopicId), fmt.Sprintf("sticky=%t", sticky))
}
return err
}
@@ -440,7 +440,7 @@ func eraseTopicRecords(ctx context.Context, tx *sqlx.Tx, topicid int32) error {
}
// Delete deletes this topic.
func (t *Topic) Delete(ctx context.Context, u *User, ipaddr string, background *util.WorkerPool) error {
func (t *Topic) Delete(ctx context.Context, u *User, comm *Community, ipaddr string, background *util.WorkerPool) error {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -472,7 +472,7 @@ func (t *Topic) Delete(ctx context.Context, u *User, ipaddr string, background *
success = true
// create audit record
ar = AmNewAudit(AuditConferenceDeleteTopic, u.Uid, ipaddr, fmt.Sprintf("confid=%d", conf.ConfId),
ar = AmNewCommAudit(AuditConferenceDeleteTopic, u.Uid, comm.Id, ipaddr, fmt.Sprintf("confid=%d", conf.ConfId),
fmt.Sprintf("topic=%d", t.TopicId))
// Spin off a background task to finish deleting this topic.
@@ -747,7 +747,7 @@ func AmListTopics(ctx context.Context, confid int32, uid int32, viewOption int,
* Standard Go error status.
*/
func AmNewTopic(ctx context.Context, conf *Conference, user *User, title string, zeroPostPseud string, zeroPost string,
zeroPostLines int32, ipaddr string) (*Topic, error) {
zeroPostLines int32, comm *Community, ipaddr string) (*Topic, error) {
var ar *AuditRecord = nil
defer func() {
AmStoreAudit(ar)
@@ -826,7 +826,7 @@ func AmNewTopic(ctx context.Context, conf *Conference, user *User, title string,
success = true
// create audit record
ar = AmNewAudit(AuditConferenceCreateTopic, user.Uid, ipaddr, fmt.Sprintf("confid=%d", conf.ConfId),
ar = AmNewCommAudit(AuditConferenceCreateTopic, user.Uid, comm.Id, ipaddr, fmt.Sprintf("confid=%d", conf.ConfId),
fmt.Sprintf("num=%d", topic.Number), fmt.Sprintf("name=%s", topic.Name))
return topic, nil