5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-10 13:20:27 +00:00
matterbridge/vendor/github.com/mattermost/mattermost-server/v5/model/compliance_post.go

125 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",
"UserType",
2016-05-21 12:14:08 +00:00
"PostId",
"PostCreateAt",
"PostUpdateAt",
"PostDeleteAt",
"PostRootId",
"PostParentId",
"PostOriginalId",
"PostMessage",
"PostType",
"PostProps",
"PostHashtags",
2016-11-12 21:00:53 +00:00
"PostFileIds",
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
}
return in
2017-08-16 21:37:37 +00:00
}
func (cp *CompliancePost) Row() []string {
2016-05-21 12:14:08 +00:00
postDeleteAt := ""
if cp.PostDeleteAt > 0 {
postDeleteAt = time.Unix(0, cp.PostDeleteAt*int64(1000*1000)).Format(time.RFC3339)
2016-05-21 12:14:08 +00:00
}
postUpdateAt := ""
if cp.PostUpdateAt != cp.PostCreateAt {
postUpdateAt = time.Unix(0, cp.PostUpdateAt*int64(1000*1000)).Format(time.RFC3339)
2016-05-21 12:14:08 +00:00
}
2020-08-09 22:29:54 +00:00
userType := "user"
if cp.IsBot {
2020-08-09 22:29:54 +00:00
userType = "bot"
}
2016-05-21 12:14:08 +00:00
return []string{
cleanComplianceStrings(cp.TeamName),
cleanComplianceStrings(cp.TeamDisplayName),
2016-05-21 12:14:08 +00:00
cleanComplianceStrings(cp.ChannelName),
cleanComplianceStrings(cp.ChannelDisplayName),
cleanComplianceStrings(cp.ChannelType),
2016-05-21 12:14:08 +00:00
cleanComplianceStrings(cp.UserUsername),
cleanComplianceStrings(cp.UserEmail),
cleanComplianceStrings(cp.UserNickname),
2020-08-09 22:29:54 +00:00
userType,
2016-05-21 12:14:08 +00:00
cp.PostId,
time.Unix(0, cp.PostCreateAt*int64(1000*1000)).Format(time.RFC3339),
2016-05-21 12:14:08 +00:00
postUpdateAt,
postDeleteAt,
cp.PostRootId,
cp.PostParentId,
cp.PostOriginalId,
cleanComplianceStrings(cp.PostMessage),
cp.PostType,
cp.PostProps,
cp.PostHashtags,
cp.PostFileIds,
2016-05-21 12:14:08 +00:00
}
}