1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"github.com/mattermost/mattermost-server/model"
"strings"
)
func ImportLineFromTeam(team *model.TeamForExport) *LineImportData {
return &LineImportData{
Type: "team",
Team: &TeamImportData{
Name: &team.Name,
DisplayName: &team.DisplayName,
Type: &team.Type,
Description: &team.Description,
AllowOpenInvite: &team.AllowOpenInvite,
Scheme: team.SchemeName,
},
}
}
func ImportLineFromChannel(channel *model.ChannelForExport) *LineImportData {
return &LineImportData{
Type: "channel",
Channel: &ChannelImportData{
Team: &channel.TeamName,
Name: &channel.Name,
DisplayName: &channel.DisplayName,
Type: &channel.Type,
Header: &channel.Header,
Purpose: &channel.Purpose,
Scheme: channel.SchemeName,
},
}
}
func ImportLineFromUser(user *model.User) *LineImportData {
// Bulk Importer doesn't accept "empty string" for AuthService.
var authService *string
if user.AuthService != "" {
authService = &user.AuthService
}
return &LineImportData{
Type: "user",
User: &UserImportData{
Username: &user.Username,
Email: &user.Email,
AuthService: authService,
AuthData: user.AuthData,
Nickname: &user.Nickname,
FirstName: &user.FirstName,
LastName: &user.LastName,
Position: &user.Position,
Roles: &user.Roles,
Locale: &user.Locale,
},
}
}
func ImportUserTeamDataFromTeamMember(member *model.TeamMemberForExport) *UserTeamImportData {
rolesList := strings.Fields(member.Roles)
if member.SchemeAdmin {
rolesList = append(rolesList, model.TEAM_ADMIN_ROLE_ID)
}
if member.SchemeUser {
rolesList = append(rolesList, model.TEAM_USER_ROLE_ID)
}
roles := strings.Join(rolesList, " ")
return &UserTeamImportData{
Name: &member.TeamName,
Roles: &roles,
}
}
func ImportUserChannelDataFromChannelMember(member *model.ChannelMemberForExport) *UserChannelImportData {
rolesList := strings.Fields(member.Roles)
if member.SchemeAdmin {
rolesList = append(rolesList, model.CHANNEL_ADMIN_ROLE_ID)
}
if member.SchemeUser {
rolesList = append(rolesList, model.CHANNEL_USER_ROLE_ID)
}
roles := strings.Join(rolesList, " ")
return &UserChannelImportData{
Name: &member.ChannelName,
Roles: &roles,
}
}
func ImportLineForPost(post *model.PostForExport) *LineImportData {
return &LineImportData{
Type: "post",
Post: &PostImportData{
Team: &post.TeamName,
Channel: &post.ChannelName,
User: &post.Username,
Message: &post.Message,
CreateAt: &post.CreateAt,
},
}
}
func ImportReplyFromPost(post *model.ReplyForExport) *ReplyImportData {
return &ReplyImportData{
User: &post.Username,
Message: &post.Message,
CreateAt: &post.CreateAt,
}
}
|