From 529fdd2643a32be5f67ea2b1d9b05d82b048658c Mon Sep 17 00:00:00 2001 From: Daniel Schalla Date: Fri, 16 Dec 2022 16:50:06 +0100 Subject: [PATCH] [MM-49170] Implement Auditable Interface for Patch Post Struct (#21898) * Implement Auditable Function for Patch Post Endpoint * Call auditable explicitly for patchPost patch parameter * Delete audit-config.json * Include HasReactions in Audit Log Entry for Patch --- api4/post.go | 3 ++- model/post.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api4/post.go b/api4/post.go index ff707c178c..34bcf21c2b 100644 --- a/api4/post.go +++ b/api4/post.go @@ -802,7 +802,8 @@ func patchPost(c *Context, w http.ResponseWriter, r *http.Request) { } auditRec := c.MakeAuditRecord("patchPost", audit.Fail) - auditRec.AddEventParameter("patch", post) + auditRec.AddEventParameter("id", c.Params.PostId) + auditRec.AddEventParameter("patch", post.Auditable()) defer c.LogAuditRecWithLevel(auditRec, app.LevelContent) // Updating the file_ids of a post is not a supported operation and will be ignored diff --git a/model/post.go b/model/post.go index 992188ac8e..2a7c4538e0 100644 --- a/model/post.go +++ b/model/post.go @@ -119,7 +119,7 @@ type Post struct { } func (o *Post) Auditable() map[string]interface{} { - return map[string]interface{}{ // TODO check this + return map[string]interface{}{ "id": o.Id, "create_at": o.CreateAt, "update_at": o.UpdateAt, @@ -195,6 +195,15 @@ func (o *PostPatch) WithRewrittenImageURLs(f func(string) string) *PostPatch { return © } +func (o *PostPatch) Auditable() map[string]interface{} { + return map[string]interface{}{ + "is_pinned": o.IsPinned, + "props": o.Props, + "file_ids": o.FileIds, + "has_reactions": o.HasReactions, + } +} + type PostForExport struct { Post TeamName string