implemented "prune attachment" on post

This commit is contained in:
2026-02-21 15:36:48 -07:00
parent 94593d3637
commit f80f63a142
7 changed files with 105 additions and 2 deletions
+1
View File
@@ -77,6 +77,7 @@ const (
AuditConferenceDelete = 315
AuditConferenceMoveMessage = 316
AuditConferenceStickyTopic = 317
AuditConferencePruneAttachment = 318
)
// auditWriteQueue is a channel to store audit records in the background.
+15
View File
@@ -223,6 +223,21 @@ func (p *PostHeader) HitAttachment(ctx context.Context) error {
return err
}
// PruneAttachment prunes (removes and deletes) the attachment of this post.
func (p *PostHeader) PruneAttachment(ctx context.Context, u *User, ipaddr string) error {
if p.ScribbleDate != nil && p.ScribbleUid != nil {
return errors.New("no attachment on scribbled post")
}
rs, err := amdb.ExecContext(ctx, "DELETE FROM postattach WHERE postid = ?", p.PostId)
if err == nil {
rowCount, err := rs.RowsAffected()
if err == nil && rowCount > 1 {
AmStoreAudit(AmNewAudit(AuditConferencePruneAttachment, u.Uid, ipaddr, fmt.Sprintf("post=%d", p.PostId)))
}
}
return err
}
// Text returns the text associated with a post.
func (p *PostHeader) Text(ctx context.Context) (string, error) {
var dbdata []PostData