5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-14 17:50:26 +00:00
matterbridge/vendor/github.com/mattermost/mattermost-server/v5/model/compliance_post.go

127 lines
2.3 KiB
Go
Raw Normal View History

2020-08-09 22:29:54 +00:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
2016-05-21 12:14:08 +00:00
package model
import (
2017-08-16 21:37:37 +00:00
"regexp"
2016-05-21 12:14:08 +00:00
"time"
)
type CompliancePost struct {
// From Team
TeamName string
TeamDisplayName string
// From Channel
ChannelName string
ChannelDisplayName string
ChannelType string
2016-05-21 12:14:08 +00:00
// From User
UserUsername string
UserEmail string
UserNickname string
// From Post
PostId string
PostCreateAt int64
PostUpdateAt int64
PostDeleteAt int64
PostRootId string
PostParentId string
PostOriginalId string
PostMessage string
PostType string
PostProps string
PostHashtags string
2016-11-12 21:00:53 +00:00
PostFileIds string
2020-08-09 22:29:54 +00:00
IsBot bool
2016-05-21 12:14:08 +00:00
}
func CompliancePostHeader() []string {
return []string{
"TeamName",
"TeamDisplayName",
"ChannelName",
"ChannelDisplayName",
"ChannelType",
2016-05-21 12:14:08 +00:00
"UserUsername",
"UserEmail",
"UserNickname",
"PostId",
"PostCreateAt",
"PostUpdateAt",
"PostDeleteAt",
"PostRootId",
"PostParentId",
"PostOriginalId",
"PostMessage",
"PostType",
"PostProps",
"PostHashtags",
2016-11-12 21:00:53 +00:00
"PostFileIds",
2020-08-09 22:29:54 +00:00
"UserType",
2016-05-21 12:14:08 +00:00
}
}
2017-08-16 21:37:37 +00:00
func cleanComplianceStrings(in string) string {
if matched, _ := regexp.MatchString("^\\s*(=|\\+|\\-)", in); matched {
return "'" + in
} else {
return in
}
}
2016-05-21 12:14:08 +00:00
func (me *CompliancePost) Row() []string {
postDeleteAt := ""
if me.PostDeleteAt > 0 {
postDeleteAt = time.Unix(0, me.PostDeleteAt*int64(1000*1000)).Format(time.RFC3339)
}
postUpdateAt := ""
if me.PostUpdateAt != me.PostCreateAt {
postUpdateAt = time.Unix(0, me.PostUpdateAt*int64(1000*1000)).Format(time.RFC3339)
}
2020-08-09 22:29:54 +00:00
userType := "user"
if me.IsBot {
userType = "bot"
}
2016-05-21 12:14:08 +00:00
return []string{
2017-08-16 21:37:37 +00:00
cleanComplianceStrings(me.TeamName),
cleanComplianceStrings(me.TeamDisplayName),
2016-05-21 12:14:08 +00:00
2017-08-16 21:37:37 +00:00
cleanComplianceStrings(me.ChannelName),
cleanComplianceStrings(me.ChannelDisplayName),
cleanComplianceStrings(me.ChannelType),
2016-05-21 12:14:08 +00:00
2017-08-16 21:37:37 +00:00
cleanComplianceStrings(me.UserUsername),
cleanComplianceStrings(me.UserEmail),
cleanComplianceStrings(me.UserNickname),
2020-08-09 22:29:54 +00:00
userType,
2016-05-21 12:14:08 +00:00
me.PostId,
time.Unix(0, me.PostCreateAt*int64(1000*1000)).Format(time.RFC3339),
postUpdateAt,
postDeleteAt,
me.PostRootId,
me.PostParentId,
me.PostOriginalId,
2017-08-16 21:37:37 +00:00
cleanComplianceStrings(me.PostMessage),
2016-05-21 12:14:08 +00:00
me.PostType,
me.PostProps,
me.PostHashtags,
2016-11-12 21:00:53 +00:00
me.PostFileIds,
2016-05-21 12:14:08 +00:00
}
}