all audit messages that were implemented but needed community ID context now have it
This commit is contained in:
+10
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user