From 31ab0c2fe6aeabd6d0b2d61a0e06486cca963ff2 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Fri, 26 Jan 2024 18:21:38 -0500 Subject: [PATCH] fix: anon claim and global mod --- server/services/v1/comments/abandon.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/services/v1/comments/abandon.go b/server/services/v1/comments/abandon.go index 727d0e5..21768ee 100644 --- a/server/services/v1/comments/abandon.go +++ b/server/services/v1/comments/abandon.go @@ -29,7 +29,19 @@ func abandon(args *commentapi.AbandonArgs) (*commentapi.CommentItem, error) { if comment.R.Channel == nil { return nil, errors.Err("channel id '%s' does not have a channel record", comment.ChannelID.String) } - commenterChannel = comment.R.Channel + // Handle anonymous content where there's no channel associated + if comment.R.Channel == nil { + // If the content is anonymous, set the modChannel to a default or system channel + // Assuming there's a function getDefaultModeratorChannel() that returns a default mod channel + if args.ModChannelName != "" && args.ModChannelID != "" { + modChannel, creatorChannel, err = helper.GetModerator(args.ModChannelID, args.ModChannelName, args.ModChannelID, args.ModChannelID) + if err != nil { + return nil, err + } + } + } else { + commenterChannel = comment.R.Channel + } // Old versions of desktop app will allow for just creator channel info to be sent for creators to // delete comments and mod channel info is newer addition and would not be sent so we cannot assume // it will sent with request.