Making private some methods that are not needed publicly (#13959)
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ccc57e56c3
Коммит
c9a0418a32
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/services/imageproxy"
|
||||
"github.com/mattermost/mattermost-server/v5/services/timezones"
|
||||
"github.com/mattermost/mattermost-server/v5/store"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
// AppIface is extracted from App struct and contains all it's exported methods. It's provided to allow partial interface passing and app layers creation.
|
||||
@@ -89,8 +88,6 @@ type AppIface interface {
|
||||
CheckUserPostflightAuthenticationCriteria(user *model.User) *model.AppError
|
||||
CheckUserPreflightAuthenticationCriteria(user *model.User, mfaToken string) *model.AppError
|
||||
ClearChannelMembersCache(channelID string)
|
||||
ClearPushNotification(currentSessionId, userId, channelId string)
|
||||
ClearPushNotificationSync(currentSessionId, userId, channelId string) *model.AppError
|
||||
ClearSessionCacheForAllUsers()
|
||||
ClearSessionCacheForAllUsersSkipClusterSend()
|
||||
ClearSessionCacheForUser(userId string)
|
||||
@@ -133,7 +130,6 @@ type AppIface interface {
|
||||
CreatePost(post *model.Post, channel *model.Channel, triggerWebhooks bool) (*model.Post, *model.AppError)
|
||||
CreatePostAsUser(post *model.Post, currentSessionId string) (*model.Post, *model.AppError)
|
||||
CreatePostMissingChannel(post *model.Post, triggerWebhooks bool) (*model.Post, *model.AppError)
|
||||
CreatePushNotificationsHub()
|
||||
CreateRole(role *model.Role) (*model.Role, *model.AppError)
|
||||
CreateScheme(scheme *model.Scheme) (*model.Scheme, *model.AppError)
|
||||
CreateSession(session *model.Session) (*model.Session, *model.AppError)
|
||||
@@ -202,16 +198,7 @@ type AppIface interface {
|
||||
EnsureDiagnosticId()
|
||||
EnvironmentConfig() map[string]interface{}
|
||||
ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *model.AppError)
|
||||
ExportAllChannels(writer io.Writer) *model.AppError
|
||||
ExportAllDirectChannels(writer io.Writer) *model.AppError
|
||||
ExportAllDirectPosts(writer io.Writer) *model.AppError
|
||||
ExportAllPosts(writer io.Writer) *model.AppError
|
||||
ExportAllTeams(writer io.Writer) *model.AppError
|
||||
ExportAllUsers(writer io.Writer) *model.AppError
|
||||
ExportCustomEmoji(writer io.Writer, file string, pathToEmojiDir string, dirNameToExportEmoji string) *model.AppError
|
||||
ExportPermissions(w io.Writer) error
|
||||
ExportVersion(writer io.Writer) *model.AppError
|
||||
ExportWriteLine(writer io.Writer, line *LineImportData) *model.AppError
|
||||
FetchSamlMetadataFromIdp(url string) ([]byte, *model.AppError)
|
||||
FileBackend() (filesstore.FileBackend, *model.AppError)
|
||||
FileExists(path string) (bool, *model.AppError)
|
||||
@@ -289,6 +276,7 @@ type AppIface interface {
|
||||
GetEnvironmentConfig() map[string]interface{}
|
||||
GetFile(fileId string) ([]byte, *model.AppError)
|
||||
GetFileInfo(fileId string) (*model.FileInfo, *model.AppError)
|
||||
GetFileInfos(page, perPage int, opt *model.GetFileInfosOptions) ([]*model.FileInfo, *model.AppError)
|
||||
GetFileInfosForPost(postId string, fromMaster bool) ([]*model.FileInfo, *model.AppError)
|
||||
GetFileInfosForPostWithMigration(postId string) ([]*model.FileInfo, *model.AppError)
|
||||
GetFlaggedPosts(userId string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
@@ -489,17 +477,6 @@ type AppIface interface {
|
||||
InvalidateAllCaches() *model.AppError
|
||||
InvalidateAllCachesSkipSend()
|
||||
InvalidateAllEmailInvites() *model.AppError
|
||||
InvalidateCacheForChannel(channel *model.Channel)
|
||||
InvalidateCacheForChannelByNameSkipClusterSend(teamId, name string)
|
||||
InvalidateCacheForChannelMembers(channelId string)
|
||||
InvalidateCacheForChannelMembersNotifyProps(channelId string)
|
||||
InvalidateCacheForChannelMembersNotifyPropsSkipClusterSend(channelId string)
|
||||
InvalidateCacheForChannelPosts(channelId string)
|
||||
InvalidateCacheForUser(userId string)
|
||||
InvalidateCacheForUserSkipClusterSend(userId string)
|
||||
InvalidateCacheForUserTeams(userId string)
|
||||
InvalidateCacheForUserTeamsSkipClusterSend(userId string)
|
||||
InvalidateCacheForWebhook(webhookId string)
|
||||
InvalidateWebConnSessionCacheForUser(userId string)
|
||||
InviteGuestsToChannels(teamId string, guestsInvite *model.GuestsInvite, senderId string) *model.AppError
|
||||
InviteGuestsToChannelsGracefully(teamId string, guestsInvite *model.GuestsInvite, senderId string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||
@@ -544,17 +521,11 @@ type AppIface interface {
|
||||
MoveCommand(team *model.Team, command *model.Command) *model.AppError
|
||||
MoveFile(oldPath, newPath string) *model.AppError
|
||||
NewClusterDiscoveryService() *ClusterDiscoveryService
|
||||
NewEmailTemplate(name, locale string) *utils.HTMLTemplate
|
||||
NewPluginAPI(manifest *model.Manifest) plugin.API
|
||||
NewWebConn(ws *websocket.Conn, session model.Session, t goi18n.TranslateFunc, locale string) *WebConn
|
||||
NewWebHub() *Hub
|
||||
Notification() einterfaces.NotificationInterface
|
||||
NotificationsLog() *mlog.Logger
|
||||
OldImportChannel(channel *model.Channel, sChannel SlackChannel, users map[string]*model.User) *model.Channel
|
||||
OldImportFile(timestamp time.Time, file io.Reader, teamId string, channelId string, userId string, fileName string) (*model.FileInfo, error)
|
||||
OldImportIncomingWebhookPost(post *model.Post, props model.StringInterface) string
|
||||
OldImportPost(post *model.Post) string
|
||||
OldImportUser(team *model.Team, user *model.User) *model.User
|
||||
OpenInteractiveDialog(request model.OpenDialogRequest) *model.AppError
|
||||
OriginChecker() func(*http.Request) bool
|
||||
OverrideIconURLIfEmoji(post *model.Post)
|
||||
@@ -662,28 +633,16 @@ type AppIface interface {
|
||||
SendAckToPushProxy(ack *model.PushNotificationAck) error
|
||||
SendAutoResponse(channel *model.Channel, receiver *model.User) (bool, *model.AppError)
|
||||
SendAutoResponseIfNecessary(channel *model.Channel, sender *model.User) (bool, *model.AppError)
|
||||
SendChangeUsernameEmail(oldUsername, newUsername, email, locale, siteURL string) *model.AppError
|
||||
SendDailyDiagnostics()
|
||||
SendDeactivateAccountEmail(email string, locale, siteURL string) *model.AppError
|
||||
SendDiagnostic(event string, properties map[string]interface{})
|
||||
SendEmailChangeEmail(oldEmail, newEmail, locale, siteURL string) *model.AppError
|
||||
SendEmailChangeVerifyEmail(newUserEmail, locale, siteURL, token string) *model.AppError
|
||||
SendEmailVerification(user *model.User, newEmail string) *model.AppError
|
||||
SendEphemeralPost(userId string, post *model.Post) *model.Post
|
||||
SendGuestInviteEmails(team *model.Team, channels []*model.Channel, senderName string, senderUserId string, invites []string, siteURL string, message string)
|
||||
SendInviteEmails(team *model.Team, senderName string, senderUserId string, invites []string, siteURL string)
|
||||
SendMail(to, subject, htmlBody string) *model.AppError
|
||||
SendMailWithEmbeddedFiles(to, subject, htmlBody string, embeddedFiles map[string]io.Reader) *model.AppError
|
||||
SendMfaChangeEmail(email string, activated bool, locale, siteURL string) *model.AppError
|
||||
SendNotificationMail(to, subject, htmlBody string) *model.AppError
|
||||
SendNotifications(post *model.Post, team *model.Team, channel *model.Channel, sender *model.User, parentPostList *model.PostList) ([]string, error)
|
||||
SendPasswordChangeEmail(email, method, locale, siteURL string) *model.AppError
|
||||
SendPasswordReset(email string, siteURL string) (bool, *model.AppError)
|
||||
SendPasswordResetEmail(email string, token *model.Token, locale, siteURL string) (bool, *model.AppError)
|
||||
SendSignInChangeEmail(email, method, locale, siteURL string) *model.AppError
|
||||
SendUserAccessTokenAddedEmail(email, locale, siteURL string) *model.AppError
|
||||
SendVerifyEmail(userEmail, locale, siteURL, token string) *model.AppError
|
||||
SendWelcomeEmail(userId string, email string, verified bool, locale, siteURL string) *model.AppError
|
||||
ServeInterPluginRequest(w http.ResponseWriter, r *http.Request, sourcePluginId, destinationPluginId string)
|
||||
ServePluginPublicRequest(w http.ResponseWriter, r *http.Request)
|
||||
ServePluginRequest(w http.ResponseWriter, r *http.Request)
|
||||
@@ -789,7 +748,6 @@ type AppIface interface {
|
||||
UpdateLastActivityAtIfNeeded(session model.Session)
|
||||
UpdateMfa(activate bool, userId, token string) *model.AppError
|
||||
UpdateMobileAppBadge(userId string)
|
||||
UpdateMobileAppBadgeSync(userId string) *model.AppError
|
||||
UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provider einterfaces.OauthProvider, service string) *model.AppError
|
||||
UpdateOauthApp(oldApp, updatedApp *model.OAuthApp) (*model.OAuthApp, *model.AppError)
|
||||
UpdateOutgoingWebhook(oldHook, updatedHook *model.OutgoingWebhook) (*model.OutgoingWebhook, *model.AppError)
|
||||
|
||||
@@ -103,7 +103,7 @@ func (a *App) JoinDefaultChannels(teamId string, user *model.User, shouldBeAdmin
|
||||
a.postJoinMessageForDefaultChannel(user, requestor, channel)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForChannelMembers(channel.Id)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_USER_ADDED, "", channel.Id, "", nil)
|
||||
message.Add("user_id", user.Id)
|
||||
@@ -254,7 +254,7 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(channel.CreatorId)
|
||||
a.invalidateCacheForUser(channel.CreatorId)
|
||||
}
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
@@ -301,8 +301,8 @@ func (a *App) GetOrCreateDirectChannel(userId, otherUserId string) (*model.Chann
|
||||
|
||||
a.WaitForChannelMembership(channel.Id, userId)
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForUser(otherUserId)
|
||||
a.invalidateCacheForUser(userId)
|
||||
a.invalidateCacheForUser(otherUserId)
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
a.Srv().Go(func() {
|
||||
@@ -424,7 +424,7 @@ func (a *App) CreateGroupChannel(userIds []string, creatorId string) (*model.Cha
|
||||
a.WaitForChannelMembership(channel.Id, creatorId)
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.invalidateCacheForUser(userId)
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_GROUP_ADDED, "", channel.Id, "", nil)
|
||||
@@ -530,7 +530,7 @@ func (a *App) UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppE
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForChannel(channel)
|
||||
a.invalidateCacheForChannel(channel)
|
||||
|
||||
messageWs := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_UPDATED, "", channel.Id, "", nil)
|
||||
messageWs.Add("channel", channel.ToJson())
|
||||
@@ -581,7 +581,7 @@ func (a *App) UpdateChannelPrivacy(oldChannel *model.Channel, user *model.User)
|
||||
return channel, err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForChannel(channel)
|
||||
a.invalidateCacheForChannel(channel)
|
||||
|
||||
messageWs := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_CONVERTED, channel.TeamId, "", "", nil)
|
||||
messageWs.Add("channel_id", channel.Id)
|
||||
@@ -621,7 +621,7 @@ func (a *App) RestoreChannel(channel *model.Channel, userId string) (*model.Chan
|
||||
return nil, err
|
||||
}
|
||||
channel.DeleteAt = 0
|
||||
a.InvalidateCacheForChannel(channel)
|
||||
a.invalidateCacheForChannel(channel)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_RESTORED, channel.TeamId, "", "", nil)
|
||||
message.Add("channel_id", channel.Id)
|
||||
@@ -777,7 +777,7 @@ func (a *App) UpdateChannelMemberRoles(channelId string, userId string, newRoles
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.invalidateCacheForUser(userId)
|
||||
return member, nil
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ func (a *App) UpdateChannelMemberSchemeRoles(channelId string, userId string, is
|
||||
message.Add("channelMember", member.ToJson())
|
||||
a.Publish(message)
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.invalidateCacheForUser(userId)
|
||||
return member, nil
|
||||
}
|
||||
|
||||
@@ -847,8 +847,8 @@ func (a *App) UpdateChannelMemberNotifyProps(data map[string]string, channelId s
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.InvalidateCacheForChannelMembersNotifyProps(channelId)
|
||||
a.invalidateCacheForUser(userId)
|
||||
a.invalidateCacheForChannelMembersNotifyProps(channelId)
|
||||
// Notify the clients that the member notify props changed
|
||||
evt := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_MEMBER_UPDATED, "", "", userId, nil)
|
||||
evt.Add("channelMember", member.ToJson())
|
||||
@@ -927,7 +927,7 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
if err := a.Srv().Store.Webhook().DeleteIncoming(hook.Id, now); err != nil {
|
||||
mlog.Error("Encountered error deleting incoming webhook", mlog.String("hook_id", hook.Id), mlog.Err(err))
|
||||
}
|
||||
a.InvalidateCacheForWebhook(hook.Id)
|
||||
a.invalidateCacheForWebhook(hook.Id)
|
||||
}
|
||||
|
||||
for _, hook := range outgoingHooks {
|
||||
@@ -941,7 +941,7 @@ func (a *App) DeleteChannel(channel *model.Channel, userId string) *model.AppErr
|
||||
if err := a.Srv().Store.Channel().Delete(channel.Id, deleteAt); err != nil {
|
||||
return err
|
||||
}
|
||||
a.InvalidateCacheForChannel(channel)
|
||||
a.invalidateCacheForChannel(channel)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_DELETED, channel.TeamId, "", "", nil)
|
||||
message.Add("channel_id", channel.Id)
|
||||
@@ -1003,8 +1003,8 @@ func (a *App) addUserToChannel(user *model.User, channel *model.Channel, teamMem
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.InvalidateCacheForChannelMembers(channel.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
return newMember, nil
|
||||
}
|
||||
@@ -1735,8 +1735,8 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userIdToRemove)
|
||||
a.InvalidateCacheForChannelMembers(channel.Id)
|
||||
a.invalidateCacheForUser(userIdToRemove)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
|
||||
if pluginsEnvironment := a.GetPluginsEnvironment(); pluginsEnvironment != nil {
|
||||
var actorUser *model.User
|
||||
@@ -2044,7 +2044,7 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
|
||||
}
|
||||
}
|
||||
for _, channelId := range channelsToClearPushNotifications {
|
||||
a.ClearPushNotification(currentSessionId, userId, channelId)
|
||||
a.clearPushNotification(currentSessionId, userId, channelId)
|
||||
}
|
||||
return times, nil
|
||||
}
|
||||
|
||||
@@ -44,19 +44,19 @@ func (a *App) clusterInvalidateAllCachesHandler(msg *model.ClusterMessage) {
|
||||
}
|
||||
|
||||
func (a *App) clusterInvalidateCacheForChannelMembersNotifyPropHandler(msg *model.ClusterMessage) {
|
||||
a.InvalidateCacheForChannelMembersNotifyPropsSkipClusterSend(msg.Data)
|
||||
a.invalidateCacheForChannelMembersNotifyPropsSkipClusterSend(msg.Data)
|
||||
}
|
||||
|
||||
func (a *App) clusterInvalidateCacheForChannelByNameHandler(msg *model.ClusterMessage) {
|
||||
a.InvalidateCacheForChannelByNameSkipClusterSend(msg.Props["id"], msg.Props["name"])
|
||||
a.invalidateCacheForChannelByNameSkipClusterSend(msg.Props["id"], msg.Props["name"])
|
||||
}
|
||||
|
||||
func (a *App) clusterInvalidateCacheForUserHandler(msg *model.ClusterMessage) {
|
||||
a.InvalidateCacheForUserSkipClusterSend(msg.Data)
|
||||
a.invalidateCacheForUserSkipClusterSend(msg.Data)
|
||||
}
|
||||
|
||||
func (a *App) clusterInvalidateCacheForUserTeamsHandler(msg *model.ClusterMessage) {
|
||||
a.InvalidateCacheForUserTeamsSkipClusterSend(msg.Data)
|
||||
a.invalidateCacheForUserTeamsSkipClusterSend(msg.Data)
|
||||
}
|
||||
|
||||
func (a *App) clusterClearSessionCacheForUserHandler(msg *model.ClusterMessage) {
|
||||
|
||||
92
app/email.go
92
app/email.go
@@ -59,28 +59,28 @@ func (a *App) SetupInviteEmailRateLimiting() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendChangeUsernameEmail(oldUsername, newUsername, email, locale, siteURL string) *model.AppError {
|
||||
func (a *App) sendChangeUsernameEmail(oldUsername, newUsername, email, locale, siteURL string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.username_change_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"],
|
||||
"TeamDisplayName": a.Config().TeamSettings.SiteName})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("email_change_body", locale)
|
||||
bodyPage := a.newEmailTemplate("email_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.username_change_body.title")
|
||||
bodyPage.Props["Info"] = T("api.templates.username_change_body.info",
|
||||
map[string]interface{}{"TeamDisplayName": a.Config().TeamSettings.SiteName, "NewUsername": newUsername})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendChangeUsernameEmail", "api.user.send_email_change_username_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("sendChangeUsernameEmail", "api.user.send_email_change_username_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendEmailChangeVerifyEmail(newUserEmail, locale, siteURL, token string) *model.AppError {
|
||||
func (a *App) sendEmailChangeVerifyEmail(newUserEmail, locale, siteURL, token string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
link := fmt.Sprintf("%s/do_verify_email?token=%s&email=%s", siteURL, token, url.QueryEscape(newUserEmail))
|
||||
@@ -89,7 +89,7 @@ func (a *App) SendEmailChangeVerifyEmail(newUserEmail, locale, siteURL, token st
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"],
|
||||
"TeamDisplayName": a.Config().TeamSettings.SiteName})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("email_change_verify_body", locale)
|
||||
bodyPage := a.newEmailTemplate("email_change_verify_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.email_change_verify_body.title")
|
||||
bodyPage.Props["Info"] = T("api.templates.email_change_verify_body.info",
|
||||
@@ -97,35 +97,35 @@ func (a *App) SendEmailChangeVerifyEmail(newUserEmail, locale, siteURL, token st
|
||||
bodyPage.Props["VerifyUrl"] = link
|
||||
bodyPage.Props["VerifyButton"] = T("api.templates.email_change_verify_body.button")
|
||||
|
||||
if err := a.SendMail(newUserEmail, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendEmailChangeVerifyEmail", "api.user.send_email_change_verify_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
if err := a.sendMail(newUserEmail, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("sendEmailChangeVerifyEmail", "api.user.send_email_change_verify_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendEmailChangeEmail(oldEmail, newEmail, locale, siteURL string) *model.AppError {
|
||||
func (a *App) sendEmailChangeEmail(oldEmail, newEmail, locale, siteURL string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.email_change_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"],
|
||||
"TeamDisplayName": a.Config().TeamSettings.SiteName})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("email_change_body", locale)
|
||||
bodyPage := a.newEmailTemplate("email_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.email_change_body.title")
|
||||
bodyPage.Props["Info"] = T("api.templates.email_change_body.info",
|
||||
map[string]interface{}{"TeamDisplayName": a.Config().TeamSettings.SiteName, "NewEmail": newEmail})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(oldEmail, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendEmailChangeEmail", "api.user.send_email_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
if err := a.sendMail(oldEmail, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("sendEmailChangeEmail", "api.user.send_email_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendVerifyEmail(userEmail, locale, siteURL, token string) *model.AppError {
|
||||
func (a *App) sendVerifyEmail(userEmail, locale, siteURL, token string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
link := fmt.Sprintf("%s/do_verify_email?token=%s&email=%s", siteURL, token, url.QueryEscape(userEmail))
|
||||
@@ -135,14 +135,14 @@ func (a *App) SendVerifyEmail(userEmail, locale, siteURL, token string) *model.A
|
||||
subject := T("api.templates.verify_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("verify_body", locale)
|
||||
bodyPage := a.newEmailTemplate("verify_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.verify_body.title", map[string]interface{}{"ServerURL": serverURL})
|
||||
bodyPage.Props["Info"] = T("api.templates.verify_body.info")
|
||||
bodyPage.Props["VerifyUrl"] = link
|
||||
bodyPage.Props["Button"] = T("api.templates.verify_body.button")
|
||||
|
||||
if err := a.SendMail(userEmail, subject, bodyPage.Render()); err != nil {
|
||||
if err := a.sendMail(userEmail, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendVerifyEmail", "api.user.send_verify_email_and_forget.failed.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -155,21 +155,21 @@ func (a *App) SendSignInChangeEmail(email, method, locale, siteURL string) *mode
|
||||
subject := T("api.templates.signin_change_email.subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("signin_change_body", locale)
|
||||
bodyPage := a.newEmailTemplate("signin_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.signin_change_email.body.title")
|
||||
bodyPage.Props["Info"] = T("api.templates.signin_change_email.body.info",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "Method": method})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendSignInChangeEmail", "api.user.send_sign_in_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendWelcomeEmail(userId string, email string, verified bool, locale, siteURL string) *model.AppError {
|
||||
func (a *App) sendWelcomeEmail(userId string, email string, verified bool, locale, siteURL string) *model.AppError {
|
||||
if !*a.Config().EmailSettings.SendEmailNotifications && !*a.Config().EmailSettings.RequireEmailVerification {
|
||||
return model.NewAppError("SendWelcomeEmail", "api.user.send_welcome_email_and_forget.failed.error", nil, "Send Email Notifications and Require Email Verification is disabled in the system console", http.StatusInternalServerError)
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func (a *App) SendWelcomeEmail(userId string, email string, verified bool, local
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"],
|
||||
"ServerURL": serverURL})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("welcome_body", locale)
|
||||
bodyPage := a.newEmailTemplate("welcome_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.welcome_body.title", map[string]interface{}{"ServerURL": serverURL})
|
||||
bodyPage.Props["Info"] = T("api.templates.welcome_body.info")
|
||||
@@ -205,49 +205,49 @@ func (a *App) SendWelcomeEmail(userId string, email string, verified bool, local
|
||||
bodyPage.Props["VerifyUrl"] = link
|
||||
}
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendWelcomeEmail", "api.user.send_welcome_email_and_forget.failed.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("sendWelcomeEmail", "api.user.send_welcome_email_and_forget.failed.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendPasswordChangeEmail(email, method, locale, siteURL string) *model.AppError {
|
||||
func (a *App) sendPasswordChangeEmail(email, method, locale, siteURL string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.password_change_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"],
|
||||
"TeamDisplayName": a.Config().TeamSettings.SiteName})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("password_change_body", locale)
|
||||
bodyPage := a.newEmailTemplate("password_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.password_change_body.title")
|
||||
bodyPage.Props["Info"] = T("api.templates.password_change_body.info",
|
||||
map[string]interface{}{"TeamDisplayName": a.Config().TeamSettings.SiteName, "TeamURL": siteURL, "Method": method})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendPasswordChangeEmail", "api.user.send_password_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("sendPasswordChangeEmail", "api.user.send_password_change_email_and_forget.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendUserAccessTokenAddedEmail(email, locale, siteURL string) *model.AppError {
|
||||
func (a *App) sendUserAccessTokenAddedEmail(email, locale, siteURL string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.user_access_token_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("password_change_body", locale)
|
||||
bodyPage := a.newEmailTemplate("password_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.user_access_token_body.title")
|
||||
bodyPage.Props["Info"] = T("api.templates.user_access_token_body.info",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], "SiteURL": siteURL})
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendUserAccessTokenAddedEmail", "api.user.send_user_access_token.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("sendUserAccessTokenAddedEmail", "api.user.send_user_access_token.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -261,7 +261,7 @@ func (a *App) SendPasswordResetEmail(email string, token *model.Token, locale, s
|
||||
subject := T("api.templates.reset_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("reset_body", locale)
|
||||
bodyPage := a.newEmailTemplate("reset_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.reset_body.title")
|
||||
bodyPage.Props["Info1"] = utils.TranslateAsHtml(T, "api.templates.reset_body.info1", nil)
|
||||
@@ -269,20 +269,20 @@ func (a *App) SendPasswordResetEmail(email string, token *model.Token, locale, s
|
||||
bodyPage.Props["ResetUrl"] = link
|
||||
bodyPage.Props["Button"] = T("api.templates.reset_body.button")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return false, model.NewAppError("SendPasswordReset", "api.user.send_password_reset.send.app_error", nil, "err="+err.Message, http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (a *App) SendMfaChangeEmail(email string, activated bool, locale, siteURL string) *model.AppError {
|
||||
func (a *App) sendMfaChangeEmail(email string, activated bool, locale, siteURL string) *model.AppError {
|
||||
T := utils.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.mfa_change_subject",
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("mfa_change_body", locale)
|
||||
bodyPage := a.newEmailTemplate("mfa_change_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
|
||||
if activated {
|
||||
@@ -294,7 +294,7 @@ func (a *App) SendMfaChangeEmail(email string, activated bool, locale, siteURL s
|
||||
}
|
||||
bodyPage.Props["Warning"] = T("api.templates.email_warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendMfaChangeEmail", "api.user.send_mfa_change_email.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ func (a *App) SendInviteEmails(team *model.Team, senderName string, senderUserId
|
||||
"TeamDisplayName": team.DisplayName,
|
||||
"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("invite_body", model.DEFAULT_LOCALE)
|
||||
bodyPage := a.newEmailTemplate("invite_body", model.DEFAULT_LOCALE)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = utils.T("api.templates.invite_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body.info",
|
||||
@@ -355,14 +355,14 @@ func (a *App) SendInviteEmails(team *model.Team, senderName string, senderUserId
|
||||
}
|
||||
bodyPage.Props["Link"] = fmt.Sprintf("%s/signup_user_complete/?d=%s&t=%s", siteURL, url.QueryEscape(data), url.QueryEscape(token.Token))
|
||||
|
||||
if err := a.SendMail(invite, subject, bodyPage.Render()); err != nil {
|
||||
if err := a.sendMail(invite, subject, bodyPage.Render()); err != nil {
|
||||
mlog.Error("Failed to send invite email successfully ", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) SendGuestInviteEmails(team *model.Team, channels []*model.Channel, senderName string, senderUserId string, invites []string, siteURL string, message string) {
|
||||
func (a *App) sendGuestInviteEmails(team *model.Team, channels []*model.Channel, senderName string, senderUserId string, invites []string, siteURL string, message string) {
|
||||
if a.Srv().EmailRateLimiter == nil {
|
||||
a.Log().Error("Email invite not sent, rate limiting could not be setup.", mlog.String("user_id", senderUserId), mlog.String("team_id", team.Id))
|
||||
return
|
||||
@@ -400,7 +400,7 @@ func (a *App) SendGuestInviteEmails(team *model.Team, channels []*model.Channel,
|
||||
"TeamDisplayName": team.DisplayName,
|
||||
"SiteName": a.ClientConfig()["SiteName"]})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("invite_body", model.DEFAULT_LOCALE)
|
||||
bodyPage := a.newEmailTemplate("invite_body", model.DEFAULT_LOCALE)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = utils.T("api.templates.invite_body.title")
|
||||
bodyPage.Html["Info"] = utils.TranslateAsHtml(utils.T, "api.templates.invite_body_guest.info",
|
||||
@@ -456,14 +456,14 @@ func (a *App) SendGuestInviteEmails(team *model.Team, channels []*model.Channel,
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.SendMailWithEmbeddedFiles(invite, subject, bodyPage.Render(), embeddedFiles); err != nil {
|
||||
if err := a.sendMailWithEmbeddedFiles(invite, subject, bodyPage.Render(), embeddedFiles); err != nil {
|
||||
mlog.Error("Failed to send invite email successfully", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) NewEmailTemplate(name, locale string) *utils.HTMLTemplate {
|
||||
func (a *App) newEmailTemplate(name, locale string) *utils.HTMLTemplate {
|
||||
t := utils.NewHTMLTemplate(a.HTMLTemplates(), name)
|
||||
|
||||
var localT i18n.TranslateFunc
|
||||
@@ -499,33 +499,33 @@ func (a *App) SendDeactivateAccountEmail(email string, locale, siteURL string) *
|
||||
map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"],
|
||||
"ServerURL": serverURL})
|
||||
|
||||
bodyPage := a.NewEmailTemplate("deactivate_body", locale)
|
||||
bodyPage := a.newEmailTemplate("deactivate_body", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.deactivate_body.title", map[string]interface{}{"ServerURL": serverURL})
|
||||
bodyPage.Props["Info"] = T("api.templates.deactivate_body.info",
|
||||
map[string]interface{}{"SiteURL": siteURL})
|
||||
bodyPage.Props["Warning"] = T("api.templates.deactivate_body.warning")
|
||||
|
||||
if err := a.SendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
if err := a.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
return model.NewAppError("SendDeactivateEmail", "api.user.send_deactivate_email_and_forget.failed.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendNotificationMail(to, subject, htmlBody string) *model.AppError {
|
||||
func (a *App) sendNotificationMail(to, subject, htmlBody string) *model.AppError {
|
||||
if !*a.Config().EmailSettings.SendEmailNotifications {
|
||||
return nil
|
||||
}
|
||||
return a.SendMail(to, subject, htmlBody)
|
||||
return a.sendMail(to, subject, htmlBody)
|
||||
}
|
||||
|
||||
func (a *App) SendMail(to, subject, htmlBody string) *model.AppError {
|
||||
func (a *App) sendMail(to, subject, htmlBody string) *model.AppError {
|
||||
license := a.License()
|
||||
return mailservice.SendMailUsingConfig(to, subject, htmlBody, a.Config(), license != nil && *license.Features.Compliance)
|
||||
}
|
||||
|
||||
func (a *App) SendMailWithEmbeddedFiles(to, subject, htmlBody string, embeddedFiles map[string]io.Reader) *model.AppError {
|
||||
func (a *App) sendMailWithEmbeddedFiles(to, subject, htmlBody string, embeddedFiles map[string]io.Reader) *model.AppError {
|
||||
license := a.License()
|
||||
config := a.Config()
|
||||
|
||||
|
||||
@@ -235,12 +235,12 @@ func (s *Server) sendBatchedEmailNotification(userId string, notifications []*ba
|
||||
"Day": tm.Day(),
|
||||
})
|
||||
|
||||
body := s.FakeApp().NewEmailTemplate("post_batched_body", user.Locale)
|
||||
body := s.FakeApp().newEmailTemplate("post_batched_body", user.Locale)
|
||||
body.Props["SiteURL"] = *s.Config().ServiceSettings.SiteURL
|
||||
body.Props["Posts"] = template.HTML(contents)
|
||||
body.Props["BodyText"] = translateFunc("api.email_batching.send_batched_email_notification.body_text", len(notifications))
|
||||
|
||||
if err := s.FakeApp().SendNotificationMail(user.Email, subject, body.Render()); err != nil {
|
||||
if err := s.FakeApp().sendNotificationMail(user.Email, subject, body.Render()); err != nil {
|
||||
mlog.Warn("Unable to send batched email notification", mlog.String("email", user.Email), mlog.Err(err))
|
||||
}
|
||||
}
|
||||
@@ -249,9 +249,9 @@ func (s *Server) renderBatchedPost(notification *batchedNotification, channel *m
|
||||
// don't include message contents if email notification contents type is set to generic
|
||||
var template *utils.HTMLTemplate
|
||||
if emailNotificationContentsType == model.EMAIL_NOTIFICATION_CONTENTS_FULL {
|
||||
template = s.FakeApp().NewEmailTemplate("post_batched_post_full", userLocale)
|
||||
template = s.FakeApp().newEmailTemplate("post_batched_post_full", userLocale)
|
||||
} else {
|
||||
template = s.FakeApp().NewEmailTemplate("post_batched_post_generic", userLocale)
|
||||
template = s.FakeApp().newEmailTemplate("post_batched_post_generic", userLocale)
|
||||
}
|
||||
|
||||
template.Props["Button"] = translateFunc("api.email_batching.render_batched_post.go_to_post")
|
||||
|
||||
@@ -55,49 +55,49 @@ var exportablePreferences = map[ComparablePreference]string{{
|
||||
|
||||
func (a *App) BulkExport(writer io.Writer, file string, pathToEmojiDir string, dirNameToExportEmoji string) *model.AppError {
|
||||
mlog.Info("Bulk export: exporting version")
|
||||
if err := a.ExportVersion(writer); err != nil {
|
||||
if err := a.exportVersion(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting teams")
|
||||
if err := a.ExportAllTeams(writer); err != nil {
|
||||
if err := a.exportAllTeams(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting channels")
|
||||
if err := a.ExportAllChannels(writer); err != nil {
|
||||
if err := a.exportAllChannels(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting users")
|
||||
if err := a.ExportAllUsers(writer); err != nil {
|
||||
if err := a.exportAllUsers(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting posts")
|
||||
if err := a.ExportAllPosts(writer); err != nil {
|
||||
if err := a.exportAllPosts(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting emoji")
|
||||
if err := a.ExportCustomEmoji(writer, file, pathToEmojiDir, dirNameToExportEmoji); err != nil {
|
||||
if err := a.exportCustomEmoji(writer, file, pathToEmojiDir, dirNameToExportEmoji); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting direct channels")
|
||||
if err := a.ExportAllDirectChannels(writer); err != nil {
|
||||
if err := a.exportAllDirectChannels(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mlog.Info("Bulk export: exporting direct posts")
|
||||
if err := a.ExportAllDirectPosts(writer); err != nil {
|
||||
if err := a.exportAllDirectPosts(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ExportWriteLine(writer io.Writer, line *LineImportData) *model.AppError {
|
||||
func (a *App) exportWriteLine(writer io.Writer, line *LineImportData) *model.AppError {
|
||||
b, err := json.Marshal(line)
|
||||
if err != nil {
|
||||
return model.NewAppError("BulkExport", "app.export.export_write_line.json_marshall.error", nil, "err="+err.Error(), http.StatusBadRequest)
|
||||
@@ -110,17 +110,17 @@ func (a *App) ExportWriteLine(writer io.Writer, line *LineImportData) *model.App
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ExportVersion(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportVersion(writer io.Writer) *model.AppError {
|
||||
version := 1
|
||||
versionLine := &LineImportData{
|
||||
Type: "version",
|
||||
Version: &version,
|
||||
}
|
||||
|
||||
return a.ExportWriteLine(writer, versionLine)
|
||||
return a.exportWriteLine(writer, versionLine)
|
||||
}
|
||||
|
||||
func (a *App) ExportAllTeams(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportAllTeams(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
teams, err := a.Srv().Store.Team().GetAllForExportAfter(1000, afterId)
|
||||
@@ -142,7 +142,7 @@ func (a *App) ExportAllTeams(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
teamLine := ImportLineFromTeam(team)
|
||||
if err := a.ExportWriteLine(writer, teamLine); err != nil {
|
||||
if err := a.exportWriteLine(writer, teamLine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ func (a *App) ExportAllTeams(writer io.Writer) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ExportAllChannels(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportAllChannels(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
channels, err := a.Srv().Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
|
||||
@@ -173,7 +173,7 @@ func (a *App) ExportAllChannels(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
channelLine := ImportLineFromChannel(channel)
|
||||
if err := a.ExportWriteLine(writer, channelLine); err != nil {
|
||||
if err := a.exportWriteLine(writer, channelLine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ func (a *App) ExportAllChannels(writer io.Writer) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ExportAllUsers(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportAllUsers(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
users, err := a.Srv().Store.User().GetAllAfter(1000, afterId)
|
||||
@@ -248,7 +248,7 @@ func (a *App) ExportAllUsers(writer io.Writer) *model.AppError {
|
||||
|
||||
userLine.User.Teams = members
|
||||
|
||||
if err := a.ExportWriteLine(writer, userLine); err != nil {
|
||||
if err := a.exportWriteLine(writer, userLine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -335,7 +335,7 @@ func (a *App) buildUserNotifyProps(notifyProps model.StringMap) *UserNotifyProps
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) ExportAllPosts(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportAllPosts(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
|
||||
for {
|
||||
@@ -371,7 +371,7 @@ func (a *App) ExportAllPosts(writer io.Writer) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.ExportWriteLine(writer, postLine); err != nil {
|
||||
if err := a.exportWriteLine(writer, postLine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ func (a *App) BuildPostReactions(postId string) (*[]ReactionImportData, *model.A
|
||||
|
||||
}
|
||||
|
||||
func (a *App) ExportCustomEmoji(writer io.Writer, file string, pathToEmojiDir string, dirNameToExportEmoji string) *model.AppError {
|
||||
func (a *App) exportCustomEmoji(writer io.Writer, file string, pathToEmojiDir string, dirNameToExportEmoji string) *model.AppError {
|
||||
pageNumber := 0
|
||||
for {
|
||||
customEmojiList, err := a.GetEmojiList(pageNumber, 100, model.EMOJI_SORT_BY_NAME)
|
||||
@@ -453,7 +453,7 @@ func (a *App) ExportCustomEmoji(writer io.Writer, file string, pathToEmojiDir st
|
||||
|
||||
emojiImportObject := ImportLineFromEmoji(emoji, filePath)
|
||||
|
||||
if err := a.ExportWriteLine(writer, emojiImportObject); err != nil {
|
||||
if err := a.exportWriteLine(writer, emojiImportObject); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ExportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
channels, err := a.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterId)
|
||||
@@ -533,7 +533,7 @@ func (a *App) ExportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
channelLine := ImportLineFromDirectChannel(channel)
|
||||
if err := a.ExportWriteLine(writer, channelLine); err != nil {
|
||||
if err := a.exportWriteLine(writer, channelLine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -542,7 +542,7 @@ func (a *App) ExportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) ExportAllDirectPosts(writer io.Writer) *model.AppError {
|
||||
func (a *App) exportAllDirectPosts(writer io.Writer) *model.AppError {
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
posts, err := a.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, afterId)
|
||||
@@ -570,7 +570,7 @@ func (a *App) ExportAllDirectPosts(writer io.Writer) *model.AppError {
|
||||
|
||||
postLine := ImportLineForDirectPost(post)
|
||||
postLine.DirectPost.Replies = replies
|
||||
if err := a.ExportWriteLine(writer, postLine); err != nil {
|
||||
if err := a.exportWriteLine(writer, postLine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func TestExportCustomEmoji(t *testing.T) {
|
||||
dirNameToExportEmoji := "exported_emoji_test"
|
||||
defer os.RemoveAll("../" + dirNameToExportEmoji)
|
||||
|
||||
err = th.App.ExportCustomEmoji(fileWriter, filePath, pathToEmojiDir, dirNameToExportEmoji)
|
||||
err = th.App.exportCustomEmoji(fileWriter, filePath, pathToEmojiDir, dirNameToExportEmoji)
|
||||
require.Nil(t, err, "should not have failed")
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (a *App) sendNotificationEmail(notification *PostNotification, user *model.
|
||||
var bodyText = a.getNotificationEmailBody(user, post, channel, channelName, senderName, team.Name, landingURL, emailNotificationContentsType, useMilitaryTime, translateFunc)
|
||||
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendNotificationMail(user.Email, html.UnescapeString(subjectText), bodyText); err != nil {
|
||||
if err := a.sendNotificationMail(user.Email, html.UnescapeString(subjectText), bodyText); err != nil {
|
||||
mlog.Error("Error while sending the email", mlog.String("user_email", user.Email), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -166,13 +166,13 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
// only include message contents in notification email if email notification contents type is set to full
|
||||
var bodyPage *utils.HTMLTemplate
|
||||
if emailNotificationContentsType == model.EMAIL_NOTIFICATION_CONTENTS_FULL {
|
||||
bodyPage = a.NewEmailTemplate("post_body_full", recipient.Locale)
|
||||
bodyPage = a.newEmailTemplate("post_body_full", recipient.Locale)
|
||||
postMessage := a.GetMessageForNotification(post, translateFunc)
|
||||
postMessage = html.EscapeString(postMessage)
|
||||
normalizedPostMessage := a.generateHyperlinkForChannels(postMessage, teamName, landingURL)
|
||||
bodyPage.Props["PostMessage"] = template.HTML(normalizedPostMessage)
|
||||
} else {
|
||||
bodyPage = a.NewEmailTemplate("post_body_generic", recipient.Locale)
|
||||
bodyPage = a.newEmailTemplate("post_body_generic", recipient.Locale)
|
||||
}
|
||||
|
||||
bodyPage.Props["SiteURL"] = a.GetSiteURL()
|
||||
|
||||
@@ -208,7 +208,7 @@ func (a *App) getPushNotificationMessage(contentsConfig, postMessage string, exp
|
||||
return senderName + userLocale("api.post.send_notifications_and_forget.push_general_message")
|
||||
}
|
||||
|
||||
func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId string) *model.AppError {
|
||||
func (a *App) clearPushNotificationSync(currentSessionId, userId, channelId string) *model.AppError {
|
||||
msg := &model.PushNotification{
|
||||
Type: model.PUSH_TYPE_CLEAR,
|
||||
Version: model.PUSH_MESSAGE_V2,
|
||||
@@ -226,7 +226,7 @@ func (a *App) ClearPushNotificationSync(currentSessionId, userId, channelId stri
|
||||
return a.sendPushNotificationToAllSessions(msg, userId, currentSessionId)
|
||||
}
|
||||
|
||||
func (a *App) ClearPushNotification(currentSessionId, userId, channelId string) {
|
||||
func (a *App) clearPushNotification(currentSessionId, userId, channelId string) {
|
||||
channel := a.Srv().PushNotificationsHub.GetGoChannelFromUserId(userId)
|
||||
channel <- PushNotification{
|
||||
notificationType: NOTIFICATION_TYPE_CLEAR,
|
||||
@@ -236,7 +236,7 @@ func (a *App) ClearPushNotification(currentSessionId, userId, channelId string)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) UpdateMobileAppBadgeSync(userId string) *model.AppError {
|
||||
func (a *App) updateMobileAppBadgeSync(userId string) *model.AppError {
|
||||
msg := &model.PushNotification{
|
||||
Type: model.PUSH_TYPE_UPDATE_BADGE,
|
||||
Version: model.PUSH_MESSAGE_V2,
|
||||
@@ -262,7 +262,7 @@ func (a *App) UpdateMobileAppBadge(userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) CreatePushNotificationsHub() {
|
||||
func (a *App) createPushNotificationsHub() {
|
||||
hub := PushNotificationsHub{
|
||||
Channels: []chan PushNotification{},
|
||||
}
|
||||
@@ -278,7 +278,7 @@ func (a *App) pushNotificationWorker(notifications chan PushNotification) {
|
||||
|
||||
switch notification.notificationType {
|
||||
case NOTIFICATION_TYPE_CLEAR:
|
||||
err = a.ClearPushNotificationSync(notification.currentSessionId, notification.userId, notification.channelId)
|
||||
err = a.clearPushNotificationSync(notification.currentSessionId, notification.userId, notification.channelId)
|
||||
case NOTIFICATION_TYPE_MESSAGE:
|
||||
err = a.sendPushNotificationSync(
|
||||
notification.post,
|
||||
@@ -291,7 +291,7 @@ func (a *App) pushNotificationWorker(notifications chan PushNotification) {
|
||||
notification.replyToThreadType,
|
||||
)
|
||||
case NOTIFICATION_TYPE_UPDATE_BADGE:
|
||||
err = a.UpdateMobileAppBadgeSync(notification.userId)
|
||||
err = a.updateMobileAppBadgeSync(notification.userId)
|
||||
default:
|
||||
mlog.Error("Invalid notification type", mlog.String("notification_type", string(notification.notificationType)))
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ func (api *PluginAPI) SendMail(to, subject, htmlBody string) *model.AppError {
|
||||
return model.NewAppError("SendMail", "plugin_api.send_mail.missing_htmlbody", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return api.app.SendNotificationMail(to, subject, htmlBody)
|
||||
return api.app.sendNotificationMail(to, subject, htmlBody)
|
||||
}
|
||||
|
||||
// Plugin Section
|
||||
|
||||
@@ -412,8 +412,8 @@ func (a *App) handlePostEvents(post *model.Post, user *model.User, channel *mode
|
||||
team = &model.Team{}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForChannel(channel)
|
||||
a.InvalidateCacheForChannelPosts(channel.Id)
|
||||
a.invalidateCacheForChannel(channel)
|
||||
a.invalidateCacheForChannelPosts(channel.Id)
|
||||
|
||||
if _, err := a.SendNotifications(post, team, channel, user, parentPostList); err != nil {
|
||||
return err
|
||||
@@ -604,7 +604,7 @@ func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model
|
||||
message.Add("post", rpost.ToJson())
|
||||
a.Publish(message)
|
||||
|
||||
a.InvalidateCacheForChannelPosts(rpost.ChannelId)
|
||||
a.invalidateCacheForChannelPosts(rpost.ChannelId)
|
||||
|
||||
return rpost, nil
|
||||
}
|
||||
@@ -878,7 +878,7 @@ func (a *App) DeletePost(postId, deleteByID string) (*model.Post, *model.AppErro
|
||||
})
|
||||
}
|
||||
|
||||
a.InvalidateCacheForChannelPosts(post.ChannelId)
|
||||
a.invalidateCacheForChannelPosts(post.ChannelId)
|
||||
|
||||
return post, nil
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (a *App) SaveReactionForPost(reaction *model.Reaction) (*model.Reaction, *m
|
||||
}
|
||||
|
||||
// The post is always modified since the UpdateAt always changes
|
||||
a.InvalidateCacheForChannelPosts(post.ChannelId)
|
||||
a.invalidateCacheForChannelPosts(post.ChannelId)
|
||||
|
||||
a.Srv().Go(func() {
|
||||
a.sendReactionEvent(model.WEBSOCKET_EVENT_REACTION_ADDED, reaction, post, true)
|
||||
@@ -119,7 +119,7 @@ func (a *App) DeleteReactionForPost(reaction *model.Reaction) *model.AppError {
|
||||
}
|
||||
|
||||
// The post is always modified since the UpdateAt always changes
|
||||
a.InvalidateCacheForChannelPosts(post.ChannelId)
|
||||
a.invalidateCacheForChannelPosts(post.ChannelId)
|
||||
|
||||
a.Srv().Go(func() {
|
||||
a.sendReactionEvent(model.WEBSOCKET_EVENT_REACTION_REMOVED, reaction, post, hasReactions)
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
// Don't add anything new here, new initialization should be done in the server and
|
||||
// performed in the NewServer function.
|
||||
func (s *Server) RunOldAppInitialization() error {
|
||||
s.FakeApp().CreatePushNotificationsHub()
|
||||
s.FakeApp().createPushNotificationsHub()
|
||||
|
||||
if err := utils.InitTranslations(s.FakeApp().Config().LocalizationSettings); err != nil {
|
||||
return errors.Wrapf(err, "unable to load Mattermost translation files")
|
||||
|
||||
@@ -304,7 +304,7 @@ func (a *App) CreateUserAccessToken(token *model.UserAccessToken) (*model.UserAc
|
||||
|
||||
// Don't send emails to bot users.
|
||||
if !user.IsBot {
|
||||
if err := a.SendUserAccessTokenAddedEmail(user.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendUserAccessTokenAddedEmail(user.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
a.Log().Error("Unable to send user access token added email", mlog.Err(err), mlog.String("user_id", user.Id))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ func (a *App) SlackAddUsers(teamId string, slackusers []SlackUser, importerLog *
|
||||
Password: password,
|
||||
}
|
||||
|
||||
mUser := a.OldImportUser(team, &newUser)
|
||||
mUser := a.oldImportUser(team, &newUser)
|
||||
if mUser == nil {
|
||||
importerLog.WriteString(utils.T("api.slackimport.slack_add_users.unable_import", map[string]interface{}{"Username": sUser.Username}))
|
||||
continue
|
||||
@@ -225,7 +225,7 @@ func (a *App) SlackAddBotUser(teamId string, log *bytes.Buffer) *model.User {
|
||||
Password: password,
|
||||
}
|
||||
|
||||
mUser := a.OldImportUser(team, &botUser)
|
||||
mUser := a.oldImportUser(team, &botUser)
|
||||
if mUser == nil {
|
||||
log.WriteString(utils.T("api.slackimport.slack_add_bot_user.unable_import", map[string]interface{}{"Username": username}))
|
||||
return nil
|
||||
@@ -275,7 +275,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
newPost.RootId = threads[sPost.ThreadTS]
|
||||
newPost.ParentId = threads[sPost.ThreadTS]
|
||||
}
|
||||
postId := a.OldImportPost(&newPost)
|
||||
postId := a.oldImportPost(&newPost)
|
||||
// If post is thread starter
|
||||
if sPost.ThreadTS == sPost.TimeStamp {
|
||||
threads[sPost.ThreadTS] = postId
|
||||
@@ -299,7 +299,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
Message: sPost.Comment.Comment,
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
}
|
||||
a.OldImportPost(&newPost)
|
||||
a.oldImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "bot_message":
|
||||
if botUser == nil {
|
||||
mlog.Warn("Slack Import: Unable to import the bot message as the bot user does not exist.")
|
||||
@@ -324,7 +324,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
Type: model.POST_SLACK_ATTACHMENT,
|
||||
}
|
||||
|
||||
postId := a.OldImportIncomingWebhookPost(post, props)
|
||||
postId := a.oldImportIncomingWebhookPost(post, props)
|
||||
// If post is thread starter
|
||||
if sPost.ThreadTS == sPost.TimeStamp {
|
||||
threads[sPost.ThreadTS] = postId
|
||||
@@ -356,7 +356,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
"username": users[sPost.User].Username,
|
||||
},
|
||||
}
|
||||
a.OldImportPost(&newPost)
|
||||
a.oldImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "me_message":
|
||||
if sPost.User == "" {
|
||||
mlog.Debug("Slack Import: Unable to import the message as the user field is missing.")
|
||||
@@ -372,7 +372,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
Message: "*" + sPost.Text + "*",
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
}
|
||||
postId := a.OldImportPost(&newPost)
|
||||
postId := a.oldImportPost(&newPost)
|
||||
// If post is thread starter
|
||||
if sPost.ThreadTS == sPost.TimeStamp {
|
||||
threads[sPost.ThreadTS] = postId
|
||||
@@ -393,7 +393,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
Type: model.POST_HEADER_CHANGE,
|
||||
}
|
||||
a.OldImportPost(&newPost)
|
||||
a.oldImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "channel_purpose":
|
||||
if sPost.User == "" {
|
||||
mlog.Debug("Slack Import: Unable to import the message as the user field is missing.")
|
||||
@@ -410,7 +410,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
Type: model.POST_PURPOSE_CHANGE,
|
||||
}
|
||||
a.OldImportPost(&newPost)
|
||||
a.oldImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "channel_name":
|
||||
if sPost.User == "" {
|
||||
mlog.Debug("Slack Import: Unable to import the message as the user field is missing.")
|
||||
@@ -427,7 +427,7 @@ func (a *App) SlackAddPosts(teamId string, channel *model.Channel, posts []Slack
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
Type: model.POST_DISPLAYNAME_CHANGE,
|
||||
}
|
||||
a.OldImportPost(&newPost)
|
||||
a.oldImportPost(&newPost)
|
||||
default:
|
||||
mlog.Warn(
|
||||
"Slack Import: Unable to import the message as its type is not supported",
|
||||
@@ -456,7 +456,7 @@ func (a *App) SlackUploadFile(slackPostFile *SlackFile, uploads map[string]*zip.
|
||||
defer openFile.Close()
|
||||
|
||||
timestamp := utils.TimeFromMillis(SlackConvertTimeStamp(slackTimestamp))
|
||||
uploadedFile, err := a.OldImportFile(timestamp, openFile, teamId, channelId, userId, filepath.Base(file.Name))
|
||||
uploadedFile, err := a.oldImportFile(timestamp, openFile, teamId, channelId, userId, filepath.Base(file.Name))
|
||||
if err != nil {
|
||||
mlog.Warn("Slack Import: An error occurred when uploading file.", mlog.String("file_id", slackPostFile.Id), mlog.Err(err))
|
||||
return nil, false
|
||||
@@ -544,7 +544,7 @@ func (a *App) SlackAddChannels(teamId string, slackchannels []SlackChannel, post
|
||||
|
||||
if mChannel == nil {
|
||||
// Haven't found an existing channel to merge with. Try importing it as a new one.
|
||||
mChannel = a.OldImportChannel(&newChannel, sChannel, users)
|
||||
mChannel = a.oldImportChannel(&newChannel, sChannel, users)
|
||||
if mChannel == nil {
|
||||
mlog.Warn("Slack Import: Unable to import Slack channel.", mlog.String("channel_display_name", newChannel.DisplayName))
|
||||
importerLog.WriteString(utils.T("api.slackimport.slack_add_channels.import_failed", map[string]interface{}{"DisplayName": newChannel.DisplayName}))
|
||||
@@ -552,7 +552,7 @@ func (a *App) SlackAddChannels(teamId string, slackchannels []SlackChannel, post
|
||||
}
|
||||
}
|
||||
|
||||
// Members for direct and group channels are added during the creation of the channel in the OldImportChannel function
|
||||
// Members for direct and group channels are added during the creation of the channel in the oldImportChannel function
|
||||
if sChannel.Type == model.CHANNEL_OPEN || sChannel.Type == model.CHANNEL_PRIVATE {
|
||||
a.addSlackUsersToChannel(sChannel.Members, users, mChannel, importerLog)
|
||||
}
|
||||
@@ -769,7 +769,7 @@ func (a *App) SlackImport(fileData multipart.File, fileSize int64, teamID string
|
||||
// some of the usual checks. (IsValid is still run)
|
||||
//
|
||||
|
||||
func (a *App) OldImportPost(post *model.Post) string {
|
||||
func (a *App) oldImportPost(post *model.Post) string {
|
||||
// Workaround for empty messages, which may be the case if they are webhook posts.
|
||||
firstIteration := true
|
||||
firstPostId := ""
|
||||
@@ -822,7 +822,7 @@ func (a *App) OldImportPost(post *model.Post) string {
|
||||
return firstPostId
|
||||
}
|
||||
|
||||
func (a *App) OldImportUser(team *model.Team, user *model.User) *model.User {
|
||||
func (a *App) oldImportUser(team *model.Team, user *model.User) *model.User {
|
||||
user.MakeNonNil()
|
||||
|
||||
user.Roles = model.SYSTEM_USER_ROLE_ID
|
||||
@@ -844,7 +844,7 @@ func (a *App) OldImportUser(team *model.Team, user *model.User) *model.User {
|
||||
return ruser
|
||||
}
|
||||
|
||||
func (a *App) OldImportChannel(channel *model.Channel, sChannel SlackChannel, users map[string]*model.User) *model.Channel {
|
||||
func (a *App) oldImportChannel(channel *model.Channel, sChannel SlackChannel, users map[string]*model.User) *model.Channel {
|
||||
if channel.Type == model.CHANNEL_DIRECT {
|
||||
sc, err := a.createDirectChannel(users[sChannel.Members[0]].Id, users[sChannel.Members[1]].Id)
|
||||
if err != nil {
|
||||
@@ -886,7 +886,7 @@ func (a *App) OldImportChannel(channel *model.Channel, sChannel SlackChannel, us
|
||||
return sc
|
||||
}
|
||||
|
||||
func (a *App) OldImportFile(timestamp time.Time, file io.Reader, teamId string, channelId string, userId string, fileName string) (*model.FileInfo, error) {
|
||||
func (a *App) oldImportFile(timestamp time.Time, file io.Reader, teamId string, channelId string, userId string, fileName string) (*model.FileInfo, error) {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
io.Copy(buf, file)
|
||||
data := buf.Bytes()
|
||||
@@ -907,7 +907,7 @@ func (a *App) OldImportFile(timestamp time.Time, file io.Reader, teamId string,
|
||||
return fileInfo, nil
|
||||
}
|
||||
|
||||
func (a *App) OldImportIncomingWebhookPost(post *model.Post, props model.StringInterface) string {
|
||||
func (a *App) oldImportIncomingWebhookPost(post *model.Post, props model.StringInterface) string {
|
||||
linkWithTextRegex := regexp.MustCompile(`<([^<\|]+)\|([^>]+)>`)
|
||||
post.Message = linkWithTextRegex.ReplaceAllString(post.Message, "[${2}](${1})")
|
||||
|
||||
@@ -929,5 +929,5 @@ func (a *App) OldImportIncomingWebhookPost(post *model.Post, props model.StringI
|
||||
}
|
||||
}
|
||||
|
||||
return a.OldImportPost(post)
|
||||
return a.oldImportPost(post)
|
||||
}
|
||||
|
||||
14
app/team.go
14
app/team.go
@@ -647,8 +647,8 @@ func (a *App) JoinUserToTeam(team *model.Team, user *model.User, userRequestorId
|
||||
}
|
||||
|
||||
a.ClearSessionCacheForUser(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.InvalidateCacheForUserTeams(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUserTeams(user.Id)
|
||||
|
||||
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_ADDED_TO_TEAM, "", "", user.Id, nil)
|
||||
message.Add("team_id", team.Id)
|
||||
@@ -963,8 +963,8 @@ func (a *App) RemoveTeamMemberFromTeam(teamMember *model.TeamMember, requestorId
|
||||
}
|
||||
|
||||
a.ClearSessionCacheForUser(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.InvalidateCacheForUserTeams(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUserTeams(user.Id)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -987,7 +987,7 @@ func (a *App) LeaveTeam(team *model.Team, user *model.User, requestorId string)
|
||||
|
||||
for _, channel := range *channelList {
|
||||
if !channel.IsGroupOrDirect() {
|
||||
a.InvalidateCacheForChannelMembers(channel.Id)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
if err = a.Srv().Store.Channel().RemoveMember(channel.Id, user.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1199,7 +1199,7 @@ func (a *App) InviteGuestsToChannelsGracefully(teamId string, guestsInvite *mode
|
||||
|
||||
if len(goodEmails) > 0 {
|
||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||
a.SendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, goodEmails, a.GetSiteURL(), guestsInvite.Message)
|
||||
a.sendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, goodEmails, a.GetSiteURL(), guestsInvite.Message)
|
||||
}
|
||||
|
||||
return inviteListWithErrors, nil
|
||||
@@ -1265,7 +1265,7 @@ func (a *App) InviteGuestsToChannels(teamId string, guestsInvite *model.GuestsIn
|
||||
}
|
||||
|
||||
nameFormat := *a.Config().TeamSettings.TeammateNameDisplay
|
||||
a.SendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, guestsInvite.Emails, a.GetSiteURL(), guestsInvite.Message)
|
||||
a.sendGuestInviteEmails(team, channels, user.GetDisplayName(nameFormat), user.Id, guestsInvite.Emails, a.GetSiteURL(), guestsInvite.Message)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
42
app/user.go
42
app/user.go
@@ -134,7 +134,7 @@ func (a *App) CreateUserWithInviteId(user *model.User, inviteId string) (*model.
|
||||
|
||||
a.AddDirectChannels(team.Id, ruser)
|
||||
|
||||
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send welcome email on create user with inviteId", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func (a *App) CreateUserAsAdmin(user *model.User) (*model.User, *model.AppError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send welcome email on create admin user", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ func (a *App) CreateUserFromSignup(user *model.User) (*model.User, *model.AppErr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := a.SendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendWelcomeEmail(ruser.Id, ruser.Email, ruser.EmailVerified, ruser.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send welcome email on create user from signup", mlog.Err(err))
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ func (a *App) SetDefaultProfileImage(user *model.User) *model.AppError {
|
||||
mlog.Error("Failed to reset last picture update", mlog.Err(err))
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
|
||||
updatedUser, appErr := a.GetUser(user.Id)
|
||||
if appErr != nil {
|
||||
@@ -982,7 +982,7 @@ func (a *App) invalidateUserChannelMembersCaches(userId string) *model.AppError
|
||||
}
|
||||
|
||||
for _, channel := range *channelsForUser {
|
||||
a.InvalidateCacheForChannelMembers(channel.Id)
|
||||
a.invalidateCacheForChannelMembers(channel.Id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1010,7 +1010,7 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A
|
||||
}
|
||||
|
||||
a.invalidateUserChannelMembersCaches(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
|
||||
a.sendUpdatedUserEvent(*ruser)
|
||||
|
||||
@@ -1175,7 +1175,7 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
})
|
||||
} else {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendEmailChangeEmail(userUpdate.Old.Email, userUpdate.New.Email, userUpdate.New.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendEmailChangeEmail(userUpdate.Old.Email, userUpdate.New.Email, userUpdate.New.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send email change email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -1184,14 +1184,14 @@ func (a *App) UpdateUser(user *model.User, sendNotifications bool) (*model.User,
|
||||
|
||||
if userUpdate.New.Username != userUpdate.Old.Username {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendChangeUsernameEmail(userUpdate.Old.Username, userUpdate.New.Username, userUpdate.New.Email, userUpdate.New.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendChangeUsernameEmail(userUpdate.Old.Username, userUpdate.New.Username, userUpdate.New.Email, userUpdate.New.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send change username email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv().Go(func() {
|
||||
@@ -1251,7 +1251,7 @@ func (a *App) UpdateMfa(activate bool, userId, token string) *model.AppError {
|
||||
return
|
||||
}
|
||||
|
||||
if err := a.SendMfaChangeEmail(user.Email, activate, user.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendMfaChangeEmail(user.Email, activate, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send mfa change email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -1288,7 +1288,7 @@ func (a *App) UpdatePasswordSendEmail(user *model.User, newPassword, method stri
|
||||
}
|
||||
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendPasswordChangeEmail(user.Email, method, user.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendPasswordChangeEmail(user.Email, method, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send password change email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -1435,7 +1435,7 @@ func (a *App) UpdateUserRoles(userId string, newRoles string, sendWebSocketEvent
|
||||
mlog.Error("Failed during updating user roles", mlog.Err(result.Err))
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
a.ClearSessionCacheForUser(user.Id)
|
||||
|
||||
if sendWebSocketEvent {
|
||||
@@ -1582,9 +1582,9 @@ func (a *App) SendEmailVerification(user *model.User, newEmail string) *model.Ap
|
||||
}
|
||||
|
||||
if _, err := a.GetStatus(user.Id); err != nil {
|
||||
return a.SendVerifyEmail(newEmail, user.Locale, a.GetSiteURL(), token.Token)
|
||||
return a.sendVerifyEmail(newEmail, user.Locale, a.GetSiteURL(), token.Token)
|
||||
}
|
||||
return a.SendEmailChangeVerifyEmail(newEmail, user.Locale, a.GetSiteURL(), token.Token)
|
||||
return a.sendEmailChangeVerifyEmail(newEmail, user.Locale, a.GetSiteURL(), token.Token)
|
||||
}
|
||||
|
||||
func (a *App) VerifyEmailFromToken(userSuppliedTokenString string) *model.AppError {
|
||||
@@ -1618,7 +1618,7 @@ func (a *App) VerifyEmailFromToken(userSuppliedTokenString string) *model.AppErr
|
||||
|
||||
if user.Email != tokenData.Email {
|
||||
a.Srv().Go(func() {
|
||||
if err := a.SendEmailChangeEmail(user.Email, tokenData.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
if err := a.sendEmailChangeEmail(user.Email, tokenData.Email, user.Locale, a.GetSiteURL()); err != nil {
|
||||
mlog.Error("Failed to send email change email", mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -2040,7 +2040,7 @@ func (a *App) UpdateOAuthUserAttrs(userData io.Reader, user *model.User, provide
|
||||
}
|
||||
|
||||
user = users.New
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
|
||||
if a.IsESIndexingEnabled() {
|
||||
a.Srv().Go(func() {
|
||||
@@ -2250,7 +2250,7 @@ func (a *App) getListOfAllowedChannelsForTeam(teamId string, viewRestrictions *m
|
||||
// guest roles to regular user roles.
|
||||
func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.AppError {
|
||||
err := a.Srv().Store.User().PromoteGuestToUser(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2288,7 +2288,7 @@ func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.Ap
|
||||
}
|
||||
|
||||
for _, member := range *channelMembers {
|
||||
a.InvalidateCacheForChannelMembers(member.ChannelId)
|
||||
a.invalidateCacheForChannelMembers(member.ChannelId)
|
||||
|
||||
evt := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_MEMBER_UPDATED, "", "", user.Id, nil)
|
||||
evt.Add("channelMember", member.ToJson())
|
||||
@@ -2304,7 +2304,7 @@ func (a *App) PromoteGuestToUser(user *model.User, requestorId string) *model.Ap
|
||||
// regular user roles to guest roles.
|
||||
func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
|
||||
err := a.Srv().Store.User().DemoteUserToGuest(user.Id)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.invalidateCacheForUser(user.Id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2331,7 +2331,7 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
|
||||
}
|
||||
|
||||
for _, member := range *channelMembers {
|
||||
a.InvalidateCacheForChannelMembers(member.ChannelId)
|
||||
a.invalidateCacheForChannelMembers(member.ChannelId)
|
||||
|
||||
evt := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_MEMBER_UPDATED, "", "", user.Id, nil)
|
||||
evt.Add("channelMember", member.ToJson())
|
||||
@@ -2346,7 +2346,7 @@ func (a *App) DemoteUserToGuest(user *model.User) *model.AppError {
|
||||
|
||||
// invalidateUserCacheAndPublish Invalidates cache for a user and publishes user updated event
|
||||
func (a *App) invalidateUserCacheAndPublish(userId string) {
|
||||
a.InvalidateCacheForUser(userId)
|
||||
a.invalidateCacheForUser(userId)
|
||||
|
||||
user, userErr := a.GetUser(userId)
|
||||
if userErr != nil {
|
||||
|
||||
@@ -211,9 +211,9 @@ func (a *App) PublishSkipClusterSend(message *model.WebSocketEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForChannel(channel *model.Channel) {
|
||||
func (a *App) invalidateCacheForChannel(channel *model.Channel) {
|
||||
a.Srv().Store.Channel().InvalidateChannel(channel.Id)
|
||||
a.InvalidateCacheForChannelByNameSkipClusterSend(channel.TeamId, channel.Name)
|
||||
a.invalidateCacheForChannelByNameSkipClusterSend(channel.TeamId, channel.Name)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
nameMsg := &model.ClusterMessage{
|
||||
@@ -233,14 +233,14 @@ func (a *App) InvalidateCacheForChannel(channel *model.Channel) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForChannelMembers(channelId string) {
|
||||
func (a *App) invalidateCacheForChannelMembers(channelId string) {
|
||||
a.Srv().Store.User().InvalidateProfilesInChannelCache(channelId)
|
||||
a.Srv().Store.Channel().InvalidateMemberCount(channelId)
|
||||
a.Srv().Store.Channel().InvalidateGuestCount(channelId)
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForChannelMembersNotifyProps(channelId string) {
|
||||
a.InvalidateCacheForChannelMembersNotifyPropsSkipClusterSend(channelId)
|
||||
func (a *App) invalidateCacheForChannelMembersNotifyProps(channelId string) {
|
||||
a.invalidateCacheForChannelMembersNotifyPropsSkipClusterSend(channelId)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
msg := &model.ClusterMessage{
|
||||
@@ -252,11 +252,11 @@ func (a *App) InvalidateCacheForChannelMembersNotifyProps(channelId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForChannelMembersNotifyPropsSkipClusterSend(channelId string) {
|
||||
func (a *App) invalidateCacheForChannelMembersNotifyPropsSkipClusterSend(channelId string) {
|
||||
a.Srv().Store.Channel().InvalidateCacheForChannelMembersNotifyProps(channelId)
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForChannelByNameSkipClusterSend(teamId, name string) {
|
||||
func (a *App) invalidateCacheForChannelByNameSkipClusterSend(teamId, name string) {
|
||||
if teamId == "" {
|
||||
teamId = "dm"
|
||||
}
|
||||
@@ -264,13 +264,13 @@ func (a *App) InvalidateCacheForChannelByNameSkipClusterSend(teamId, name string
|
||||
a.Srv().Store.Channel().InvalidateChannelByName(teamId, name)
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForChannelPosts(channelId string) {
|
||||
func (a *App) invalidateCacheForChannelPosts(channelId string) {
|
||||
a.Srv().Store.Channel().InvalidatePinnedPostCount(channelId)
|
||||
a.Srv().Store.Post().InvalidateLastPostTimeCache(channelId)
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForUser(userId string) {
|
||||
a.InvalidateCacheForUserSkipClusterSend(userId)
|
||||
func (a *App) invalidateCacheForUser(userId string) {
|
||||
a.invalidateCacheForUserSkipClusterSend(userId)
|
||||
|
||||
a.Srv().Store.User().InvalidateProfilesInChannelCacheByUser(userId)
|
||||
a.Srv().Store.User().InvalidateProfileCacheForUser(userId)
|
||||
@@ -285,8 +285,8 @@ func (a *App) InvalidateCacheForUser(userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForUserTeams(userId string) {
|
||||
a.InvalidateCacheForUserTeamsSkipClusterSend(userId)
|
||||
func (a *App) invalidateCacheForUserTeams(userId string) {
|
||||
a.invalidateCacheForUserTeamsSkipClusterSend(userId)
|
||||
a.Srv().Store.Team().InvalidateAllTeamIdsForUser(userId)
|
||||
|
||||
if a.Cluster() != nil {
|
||||
@@ -299,7 +299,7 @@ func (a *App) InvalidateCacheForUserTeams(userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForUserSkipClusterSend(userId string) {
|
||||
func (a *App) invalidateCacheForUserSkipClusterSend(userId string) {
|
||||
a.Srv().Store.Channel().InvalidateAllChannelMembersForUser(userId)
|
||||
|
||||
hub := a.GetHubForUserId(userId)
|
||||
@@ -308,14 +308,14 @@ func (a *App) InvalidateCacheForUserSkipClusterSend(userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForUserTeamsSkipClusterSend(userId string) {
|
||||
func (a *App) invalidateCacheForUserTeamsSkipClusterSend(userId string) {
|
||||
hub := a.GetHubForUserId(userId)
|
||||
if hub != nil {
|
||||
hub.InvalidateUser(userId)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) InvalidateCacheForWebhook(webhookId string) {
|
||||
func (a *App) invalidateCacheForWebhook(webhookId string) {
|
||||
a.Srv().Store.Webhook().InvalidateWebhookCache(webhookId)
|
||||
}
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ func (a *App) UpdateIncomingWebhook(oldHook, updatedHook *model.IncomingWebhook)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a.InvalidateCacheForWebhook(oldHook.Id)
|
||||
a.invalidateCacheForWebhook(oldHook.Id)
|
||||
return newWebhook, nil
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ func (a *App) DeleteIncomingWebhook(hookId string) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
a.InvalidateCacheForWebhook(hookId)
|
||||
a.invalidateCacheForWebhook(hookId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user