This reverts commit ea61458f16. This was causing panic in the plugins because the client and the plugin API changed with this PR
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
26b86cb3ef
Коммит
c0971970e9
@@ -93,7 +93,7 @@ type AppIface interface {
|
||||
//
|
||||
DefaultChannelNames() []string
|
||||
// DeleteBotIconImage deletes LHS icon for a bot.
|
||||
DeleteBotIconImage(botUserID string) *model.AppError
|
||||
DeleteBotIconImage(botUserId string) *model.AppError
|
||||
// DeleteChannelScheme deletes a channels scheme and sets its SchemeId to nil.
|
||||
DeleteChannelScheme(channel *model.Channel) (*model.Channel, *model.AppError)
|
||||
// DeleteGroupConstrainedMemberships deletes team and channel memberships of users who aren't members of the allowed
|
||||
@@ -137,9 +137,9 @@ type AppIface interface {
|
||||
// filter.
|
||||
GetAllLdapGroupsPage(page int, perPage int, opts model.LdapGroupSearchOpts) ([]*model.Group, int, *model.AppError)
|
||||
// GetBot returns the given bot.
|
||||
GetBot(botUserID string, includeDeleted bool) (*model.Bot, *model.AppError)
|
||||
GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model.AppError)
|
||||
// GetBotIconImage retrieves LHS icon for a bot.
|
||||
GetBotIconImage(botUserID string) ([]byte, *model.AppError)
|
||||
GetBotIconImage(botUserId string) ([]byte, *model.AppError)
|
||||
// GetBots returns the requested page of bots.
|
||||
GetBots(options *model.BotGetOptions) (model.BotList, *model.AppError)
|
||||
// GetChannelGroupUsers returns the users who are associated to the channel via GroupChannels and GroupMembers.
|
||||
@@ -243,7 +243,7 @@ type AppIface interface {
|
||||
// so that it points to the URL (relative) of the emoji - static if emoji is default, /api if custom.
|
||||
OverrideIconURLIfEmoji(post *model.Post)
|
||||
// PatchBot applies the given patch to the bot and corresponding user.
|
||||
PatchBot(botUserID string, botPatch *model.BotPatch) (*model.Bot, *model.AppError)
|
||||
PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot, *model.AppError)
|
||||
// PatchChannelModerationsForChannel Updates a channels scheme roles based on a given ChannelModerationPatch, if the permissions match the higher scoped role the scheme is deleted.
|
||||
PatchChannelModerationsForChannel(channel *model.Channel, channelModerationsPatch []*model.ChannelModerationPatch) ([]*model.ChannelModeration, *model.AppError)
|
||||
// Perform an HTTP POST request to an integration's action endpoint.
|
||||
@@ -251,7 +251,7 @@ type AppIface interface {
|
||||
// For internal requests, requests are routed directly to a plugin ServerHTTP hook
|
||||
DoActionRequest(rawURL string, body []byte) (*http.Response, *model.AppError)
|
||||
// PermanentDeleteBot permanently deletes a bot and its corresponding user.
|
||||
PermanentDeleteBot(botUserID string) *model.AppError
|
||||
PermanentDeleteBot(botUserId string) *model.AppError
|
||||
// PromoteGuestToUser Convert user's roles and all his mermbership's roles from
|
||||
// guest roles to regular user roles.
|
||||
PromoteGuestToUser(user *model.User, requestorId string) *model.AppError
|
||||
@@ -285,9 +285,9 @@ type AppIface interface {
|
||||
// SessionIsRegistered determines if a specific session has been registered
|
||||
SessionIsRegistered(session model.Session) bool
|
||||
// SetBotIconImage sets LHS icon for a bot.
|
||||
SetBotIconImage(botUserID string, file io.ReadSeeker) *model.AppError
|
||||
SetBotIconImage(botUserId string, file io.ReadSeeker) *model.AppError
|
||||
// SetBotIconImageFromMultiPartFile sets LHS icon for a bot.
|
||||
SetBotIconImageFromMultiPartFile(botUserID string, imageData *multipart.FileHeader) *model.AppError
|
||||
SetBotIconImageFromMultiPartFile(botUserId string, imageData *multipart.FileHeader) *model.AppError
|
||||
// SetSessionExpireInDays sets the session's expiry the specified number of days
|
||||
// relative to either the session creation date or the current time, depending
|
||||
// on the `ExtendSessionOnActivity` config setting.
|
||||
@@ -320,9 +320,9 @@ type AppIface interface {
|
||||
// This to be used for places we check the users password when they are already logged in
|
||||
DoubleCheckPassword(user *model.User, password string) *model.AppError
|
||||
// UpdateBotActive marks a bot as active or inactive, along with its corresponding user.
|
||||
UpdateBotActive(botUserID string, active bool) (*model.Bot, *model.AppError)
|
||||
UpdateBotActive(botUserId string, active bool) (*model.Bot, *model.AppError)
|
||||
// UpdateBotOwner changes a bot's owner to the given value.
|
||||
UpdateBotOwner(botUserID, newOwnerID string) (*model.Bot, *model.AppError)
|
||||
UpdateBotOwner(botUserId, newOwnerId string) (*model.Bot, *model.AppError)
|
||||
// UpdateChannel updates a given channel by its Id. It also publishes the CHANNEL_UPDATED event.
|
||||
UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError)
|
||||
// UpdateChannelScheme saves the new SchemeId of the channel passed.
|
||||
@@ -500,7 +500,7 @@ type AppIface interface {
|
||||
DoPostActionWithCookie(postID, actionId, userID, selectedOption string, cookie *model.PostActionCookie) (string, *model.AppError)
|
||||
DoSystemConsoleRolesCreationMigration()
|
||||
DoUploadFile(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, *model.AppError)
|
||||
DoUploadFileExpectModification(now time.Time, rawTeamID string, rawChannelID string, rawUserID string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError)
|
||||
DoUploadFileExpectModification(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError)
|
||||
DownloadFromURL(downloadURL string) ([]byte, error)
|
||||
EnableUserAccessToken(token *model.UserAccessToken) *model.AppError
|
||||
EnvironmentConfig() map[string]interface{}
|
||||
@@ -595,7 +595,7 @@ type AppIface interface {
|
||||
GetGroupsByChannel(channelID string, opts model.GroupSearchOpts) ([]*model.GroupWithSchemeAdmin, int, *model.AppError)
|
||||
GetGroupsByIDs(groupIDs []string) ([]*model.Group, *model.AppError)
|
||||
GetGroupsBySource(groupSource model.GroupSource) ([]*model.Group, *model.AppError)
|
||||
GetGroupsByUserID(userID string) ([]*model.Group, *model.AppError)
|
||||
GetGroupsByUserId(userID string) ([]*model.Group, *model.AppError)
|
||||
GetHubForUserId(userID string) *Hub
|
||||
GetIncomingWebhook(hookID string) (*model.IncomingWebhook, *model.AppError)
|
||||
GetIncomingWebhooksForTeamPage(teamID string, page, perPage int) ([]*model.IncomingWebhook, *model.AppError)
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestCheckIfRolesGrantPermission(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
roles []string
|
||||
permissionID string
|
||||
permissionId string
|
||||
shouldGrant bool
|
||||
}{
|
||||
{[]string{model.SYSTEM_ADMIN_ROLE_ID}, model.PERMISSION_MANAGE_SYSTEM.Id, true},
|
||||
@@ -35,7 +35,7 @@ func TestCheckIfRolesGrantPermission(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testcase := range cases {
|
||||
require.Equal(t, th.App.RolesGrantPermission(testcase.roles, testcase.permissionID), testcase.shouldGrant)
|
||||
require.Equal(t, th.App.RolesGrantPermission(testcase.roles, testcase.permissionId), testcase.shouldGrant)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
60
app/bot.go
60
app/bot.go
@@ -149,15 +149,15 @@ func (a *App) getOrCreateWarnMetricsBot(botDef *model.Bot) (*model.Bot, *model.A
|
||||
}
|
||||
|
||||
// PatchBot applies the given patch to the bot and corresponding user.
|
||||
func (a *App) PatchBot(botUserID string, botPatch *model.BotPatch) (*model.Bot, *model.AppError) {
|
||||
bot, err := a.GetBot(botUserID, true)
|
||||
func (a *App) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot, *model.AppError) {
|
||||
bot, err := a.GetBot(botUserId, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bot.Patch(botPatch)
|
||||
|
||||
user, nErr := a.Srv().Store.User().Get(context.Background(), botUserID)
|
||||
user, nErr := a.Srv().Store.User().Get(context.Background(), botUserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -209,8 +209,8 @@ func (a *App) PatchBot(botUserID string, botPatch *model.BotPatch) (*model.Bot,
|
||||
}
|
||||
|
||||
// GetBot returns the given bot.
|
||||
func (a *App) GetBot(botUserID string, includeDeleted bool) (*model.Bot, *model.AppError) {
|
||||
bot, err := a.Srv().Store.Bot().Get(botUserID, includeDeleted)
|
||||
func (a *App) GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model.AppError) {
|
||||
bot, err := a.Srv().Store.Bot().Get(botUserId, includeDeleted)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -233,8 +233,8 @@ func (a *App) GetBots(options *model.BotGetOptions) (model.BotList, *model.AppEr
|
||||
}
|
||||
|
||||
// UpdateBotActive marks a bot as active or inactive, along with its corresponding user.
|
||||
func (a *App) UpdateBotActive(botUserID string, active bool) (*model.Bot, *model.AppError) {
|
||||
user, nErr := a.Srv().Store.User().Get(context.Background(), botUserID)
|
||||
func (a *App) UpdateBotActive(botUserId string, active bool) (*model.Bot, *model.AppError) {
|
||||
user, nErr := a.Srv().Store.User().Get(context.Background(), botUserId)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -249,7 +249,7 @@ func (a *App) UpdateBotActive(botUserID string, active bool) (*model.Bot, *model
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bot, nErr := a.Srv().Store.Bot().Get(botUserID, true)
|
||||
bot, nErr := a.Srv().Store.Bot().Get(botUserId, true)
|
||||
if nErr != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -289,8 +289,8 @@ func (a *App) UpdateBotActive(botUserID string, active bool) (*model.Bot, *model
|
||||
}
|
||||
|
||||
// PermanentDeleteBot permanently deletes a bot and its corresponding user.
|
||||
func (a *App) PermanentDeleteBot(botUserID string) *model.AppError {
|
||||
if err := a.Srv().Store.Bot().PermanentDelete(botUserID); err != nil {
|
||||
func (a *App) PermanentDeleteBot(botUserId string) *model.AppError {
|
||||
if err := a.Srv().Store.Bot().PermanentDelete(botUserId); err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
switch {
|
||||
case errors.As(err, &invErr):
|
||||
@@ -300,7 +300,7 @@ func (a *App) PermanentDeleteBot(botUserID string) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.Srv().Store.User().PermanentDelete(botUserID); err != nil {
|
||||
if err := a.Srv().Store.User().PermanentDelete(botUserId); err != nil {
|
||||
return model.NewAppError("PermanentDeleteBot", "app.user.permanent_delete.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -308,8 +308,8 @@ func (a *App) PermanentDeleteBot(botUserID string) *model.AppError {
|
||||
}
|
||||
|
||||
// UpdateBotOwner changes a bot's owner to the given value.
|
||||
func (a *App) UpdateBotOwner(botUserID, newOwnerID string) (*model.Bot, *model.AppError) {
|
||||
bot, err := a.Srv().Store.Bot().Get(botUserID, true)
|
||||
func (a *App) UpdateBotOwner(botUserId, newOwnerId string) (*model.Bot, *model.AppError) {
|
||||
bot, err := a.Srv().Store.Bot().Get(botUserId, true)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -320,7 +320,7 @@ func (a *App) UpdateBotOwner(botUserID, newOwnerID string) (*model.Bot, *model.A
|
||||
}
|
||||
}
|
||||
|
||||
bot.OwnerId = newOwnerID
|
||||
bot.OwnerId = newOwnerId
|
||||
|
||||
bot, err = a.Srv().Store.Bot().Update(bot)
|
||||
if err != nil {
|
||||
@@ -500,7 +500,7 @@ func (a *App) ConvertUserToBot(user *model.User) (*model.Bot, *model.AppError) {
|
||||
}
|
||||
|
||||
// SetBotIconImageFromMultiPartFile sets LHS icon for a bot.
|
||||
func (a *App) SetBotIconImageFromMultiPartFile(botUserID string, imageData *multipart.FileHeader) *model.AppError {
|
||||
func (a *App) SetBotIconImageFromMultiPartFile(botUserId string, imageData *multipart.FileHeader) *model.AppError {
|
||||
file, err := imageData.Open()
|
||||
if err != nil {
|
||||
return model.NewAppError("SetBotIconImage", "api.bot.set_bot_icon_image.open.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
@@ -508,12 +508,12 @@ func (a *App) SetBotIconImageFromMultiPartFile(botUserID string, imageData *mult
|
||||
defer file.Close()
|
||||
|
||||
file.Seek(0, 0)
|
||||
return a.SetBotIconImage(botUserID, file)
|
||||
return a.SetBotIconImage(botUserId, file)
|
||||
}
|
||||
|
||||
// SetBotIconImage sets LHS icon for a bot.
|
||||
func (a *App) SetBotIconImage(botUserID string, file io.ReadSeeker) *model.AppError {
|
||||
bot, err := a.GetBot(botUserID, true)
|
||||
func (a *App) SetBotIconImage(botUserId string, file io.ReadSeeker) *model.AppError {
|
||||
bot, err := a.GetBot(botUserId, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -524,7 +524,7 @@ func (a *App) SetBotIconImage(botUserID string, file io.ReadSeeker) *model.AppEr
|
||||
|
||||
// Set icon
|
||||
file.Seek(0, 0)
|
||||
if _, err = a.WriteFile(file, getBotIconPath(botUserID)); err != nil {
|
||||
if _, err = a.WriteFile(file, getBotIconPath(botUserId)); err != nil {
|
||||
return model.NewAppError("SetBotIconImage", "api.bot.set_bot_icon_image.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -541,24 +541,24 @@ func (a *App) SetBotIconImage(botUserID string, file io.ReadSeeker) *model.AppEr
|
||||
return model.NewAppError("SetBotIconImage", "app.bot.patchbot.internal_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
a.invalidateUserCacheAndPublish(botUserID)
|
||||
a.invalidateUserCacheAndPublish(botUserId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteBotIconImage deletes LHS icon for a bot.
|
||||
func (a *App) DeleteBotIconImage(botUserID string) *model.AppError {
|
||||
bot, err := a.GetBot(botUserID, true)
|
||||
func (a *App) DeleteBotIconImage(botUserId string) *model.AppError {
|
||||
bot, err := a.GetBot(botUserId, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete icon
|
||||
if err = a.RemoveFile(getBotIconPath(botUserID)); err != nil {
|
||||
if err = a.RemoveFile(getBotIconPath(botUserId)); err != nil {
|
||||
return model.NewAppError("DeleteBotIconImage", "api.bot.delete_bot_icon_image.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if nErr := a.Srv().Store.User().UpdateLastPictureUpdate(botUserID); nErr != nil {
|
||||
if nErr := a.Srv().Store.User().UpdateLastPictureUpdate(botUserId); nErr != nil {
|
||||
mlog.Warn(nErr.Error())
|
||||
}
|
||||
|
||||
@@ -576,18 +576,18 @@ func (a *App) DeleteBotIconImage(botUserID string) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
a.invalidateUserCacheAndPublish(botUserID)
|
||||
a.invalidateUserCacheAndPublish(botUserId)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBotIconImage retrieves LHS icon for a bot.
|
||||
func (a *App) GetBotIconImage(botUserID string) ([]byte, *model.AppError) {
|
||||
if _, err := a.GetBot(botUserID, true); err != nil {
|
||||
func (a *App) GetBotIconImage(botUserId string) ([]byte, *model.AppError) {
|
||||
if _, err := a.GetBot(botUserId, true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := a.ReadFile(getBotIconPath(botUserID))
|
||||
data, err := a.ReadFile(getBotIconPath(botUserId))
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetBotIconImage", "api.bot.get_bot_icon_image.read.app_error", nil, err.Error(), http.StatusNotFound)
|
||||
}
|
||||
@@ -595,6 +595,6 @@ func (a *App) GetBotIconImage(botUserID string) ([]byte, *model.AppError) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func getBotIconPath(botUserID string) string {
|
||||
return fmt.Sprintf("bots/%v/icon.svg", botUserID)
|
||||
func getBotIconPath(botUserId string) string {
|
||||
return fmt.Sprintf("bots/%v/icon.svg", botUserId)
|
||||
}
|
||||
|
||||
@@ -273,13 +273,13 @@ func TestGetBots(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
OwnerID1 := model.NewId()
|
||||
OwnerID2 := model.NewId()
|
||||
OwnerId1 := model.NewId()
|
||||
OwnerId2 := model.NewId()
|
||||
|
||||
bot1, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username",
|
||||
Description: "a bot",
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: OwnerId1,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(bot1.UserId)
|
||||
@@ -287,7 +287,7 @@ func TestGetBots(t *testing.T) {
|
||||
deletedBot1, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username4",
|
||||
Description: "a deleted bot",
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: OwnerId1,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
deletedBot1, err = th.App.UpdateBotActive(deletedBot1.UserId, false)
|
||||
@@ -297,7 +297,7 @@ func TestGetBots(t *testing.T) {
|
||||
bot2, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username2",
|
||||
Description: "a second bot",
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: OwnerId1,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(bot2.UserId)
|
||||
@@ -305,7 +305,7 @@ func TestGetBots(t *testing.T) {
|
||||
bot3, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username3",
|
||||
Description: "a third bot",
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: OwnerId1,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(bot3.UserId)
|
||||
@@ -313,7 +313,7 @@ func TestGetBots(t *testing.T) {
|
||||
bot4, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username5",
|
||||
Description: "a fourth bot",
|
||||
OwnerId: OwnerID2,
|
||||
OwnerId: OwnerId2,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(bot4.UserId)
|
||||
@@ -321,7 +321,7 @@ func TestGetBots(t *testing.T) {
|
||||
deletedBot2, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username6",
|
||||
Description: "a deleted bot",
|
||||
OwnerId: OwnerID2,
|
||||
OwnerId: OwnerId2,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
deletedBot2, err = th.App.UpdateBotActive(deletedBot2.UserId, false)
|
||||
@@ -420,7 +420,7 @@ func TestGetBots(t *testing.T) {
|
||||
bots, err := th.App.GetBots(&model.BotGetOptions{
|
||||
Page: 0,
|
||||
PerPage: 10,
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: OwnerId1,
|
||||
IncludeDeleted: false,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
@@ -431,7 +431,7 @@ func TestGetBots(t *testing.T) {
|
||||
bots, err := th.App.GetBots(&model.BotGetOptions{
|
||||
Page: 0,
|
||||
PerPage: 10,
|
||||
OwnerId: OwnerID2,
|
||||
OwnerId: OwnerId2,
|
||||
IncludeDeleted: false,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
@@ -442,7 +442,7 @@ func TestGetBots(t *testing.T) {
|
||||
bots, err := th.App.GetBots(&model.BotGetOptions{
|
||||
Page: 0,
|
||||
PerPage: 10,
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: OwnerId1,
|
||||
IncludeDeleted: true,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
@@ -453,7 +453,7 @@ func TestGetBots(t *testing.T) {
|
||||
bots, err := th.App.GetBots(&model.BotGetOptions{
|
||||
Page: 0,
|
||||
PerPage: 10,
|
||||
OwnerId: OwnerID2,
|
||||
OwnerId: OwnerId2,
|
||||
IncludeDeleted: true,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
@@ -525,8 +525,8 @@ func TestDisableUserBots(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
OwnerID1 := model.NewId()
|
||||
OwnerID2 := model.NewId()
|
||||
ownerId1 := model.NewId()
|
||||
ownerId2 := model.NewId()
|
||||
|
||||
bots := []*model.Bot{}
|
||||
defer func() {
|
||||
@@ -539,7 +539,7 @@ func TestDisableUserBots(t *testing.T) {
|
||||
bot, err := th.App.CreateBot(&model.Bot{
|
||||
Username: fmt.Sprintf("username%v", i),
|
||||
Description: "a bot",
|
||||
OwnerId: OwnerID1,
|
||||
OwnerId: ownerId1,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
bots = append(bots, bot)
|
||||
@@ -549,12 +549,12 @@ func TestDisableUserBots(t *testing.T) {
|
||||
u2bot1, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "username_nodisable",
|
||||
Description: "a bot",
|
||||
OwnerId: OwnerID2,
|
||||
OwnerId: ownerId2,
|
||||
})
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteBot(u2bot1.UserId)
|
||||
|
||||
err = th.App.disableUserBots(OwnerID1)
|
||||
err = th.App.disableUserBots(ownerId1)
|
||||
require.Nil(t, err)
|
||||
|
||||
// Check all bots and corrensponding users are disabled for creator 1
|
||||
|
||||
@@ -158,12 +158,12 @@ func (a *App) muteChannelsForUpdatedCategories(userID string, updatedCategories
|
||||
return result
|
||||
}
|
||||
|
||||
updatedCategoriesByID := makeCategoryMap(updatedCategories)
|
||||
originalCategoriesByID := makeCategoryMap(originalCategories)
|
||||
updatedCategoriesById := makeCategoryMap(updatedCategories)
|
||||
originalCategoriesById := makeCategoryMap(originalCategories)
|
||||
|
||||
for channelID, diff := range channelsDiff {
|
||||
fromCategory := originalCategoriesByID[diff.fromCategoryID]
|
||||
toCategory := updatedCategoriesByID[diff.toCategoryID]
|
||||
fromCategory := originalCategoriesById[diff.fromCategoryId]
|
||||
toCategory := updatedCategoriesById[diff.toCategoryId]
|
||||
|
||||
if toCategory.Muted && !fromCategory.Muted {
|
||||
channelsToMute = append(channelsToMute, channelID)
|
||||
@@ -197,8 +197,8 @@ func (a *App) muteChannelsForUpdatedCategories(userID string, updatedCategories
|
||||
}
|
||||
|
||||
type categoryChannelDiff struct {
|
||||
fromCategoryID string
|
||||
toCategoryID string
|
||||
fromCategoryId string
|
||||
toCategoryId string
|
||||
}
|
||||
|
||||
func diffChannelsBetweenCategories(updatedCategories []*model.SidebarCategoryWithChannels, originalCategories []*model.SidebarCategoryWithChannels) map[string]*categoryChannelDiff {
|
||||
@@ -220,11 +220,11 @@ func diffChannelsBetweenCategories(updatedCategories []*model.SidebarCategoryWit
|
||||
// Check for any channels that have changed categories. Note that we don't worry about any channels that have moved
|
||||
// outside of these categories since that heavily complicates things and doesn't currently happen in our apps.
|
||||
channelsDiff := make(map[string]*categoryChannelDiff)
|
||||
for channelID, originalCategoryID := range originalChannelIdsMap {
|
||||
updatedCategoryID := updatedChannelIdsMap[channelID]
|
||||
for channelID, originalCategoryId := range originalChannelIdsMap {
|
||||
updatedCategoryId := updatedChannelIdsMap[channelID]
|
||||
|
||||
if originalCategoryID != updatedCategoryID && updatedCategoryID != "" {
|
||||
channelsDiff[channelID] = &categoryChannelDiff{originalCategoryID, updatedCategoryID}
|
||||
if originalCategoryId != updatedCategoryId && updatedCategoryId != "" {
|
||||
channelsDiff[channelID] = &categoryChannelDiff{originalCategoryId, updatedCategoryId}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -588,20 +588,20 @@ func TestDiffChannelsBetweenCategories(t *testing.T) {
|
||||
t,
|
||||
map[string]*categoryChannelDiff{
|
||||
"channel1": {
|
||||
fromCategoryID: "category1",
|
||||
toCategoryID: "category3",
|
||||
fromCategoryId: "category1",
|
||||
toCategoryId: "category3",
|
||||
},
|
||||
"channel2": {
|
||||
fromCategoryID: "category1",
|
||||
toCategoryID: "category2",
|
||||
fromCategoryId: "category1",
|
||||
toCategoryId: "category2",
|
||||
},
|
||||
"channel3": {
|
||||
fromCategoryID: "category1",
|
||||
toCategoryID: "category3",
|
||||
fromCategoryId: "category1",
|
||||
toCategoryId: "category3",
|
||||
},
|
||||
"channel4": {
|
||||
fromCategoryID: "category2",
|
||||
toCategoryID: "category3",
|
||||
fromCategoryId: "category2",
|
||||
toCategoryId: "category3",
|
||||
},
|
||||
},
|
||||
channelsDiff,
|
||||
@@ -649,8 +649,8 @@ func TestDiffChannelsBetweenCategories(t *testing.T) {
|
||||
t,
|
||||
map[string]*categoryChannelDiff{
|
||||
"channel3": {
|
||||
fromCategoryID: "category2",
|
||||
toCategoryID: "category1",
|
||||
fromCategoryId: "category2",
|
||||
toCategoryId: "category1",
|
||||
},
|
||||
},
|
||||
channelsDiff,
|
||||
|
||||
@@ -266,8 +266,8 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testi
|
||||
// figure out the initial number of users in town square
|
||||
channel, err := th.App.Srv().Store.Channel().GetByName(th.BasicTeam.Id, "town-square", true)
|
||||
require.NoError(t, err)
|
||||
townSquareChannelID := channel.Id
|
||||
users, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelID)
|
||||
townSquareChannelId := channel.Id
|
||||
users, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)
|
||||
require.NoError(t, nErr)
|
||||
initialNumTownSquareUsers := len(users)
|
||||
|
||||
@@ -276,13 +276,13 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordTownSquare(t *testi
|
||||
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, false, "")
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelID)
|
||||
histories, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, townSquareChannelId)
|
||||
require.NoError(t, nErr)
|
||||
assert.Len(t, histories, initialNumTownSquareUsers+1)
|
||||
|
||||
found := false
|
||||
for _, history := range histories {
|
||||
if user.Id == history.UserId && townSquareChannelID == history.ChannelId {
|
||||
if user.Id == history.UserId && townSquareChannelId == history.ChannelId {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -297,8 +297,8 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordOffTopic(t *testing
|
||||
// figure out the initial number of users in off-topic
|
||||
channel, err := th.App.Srv().Store.Channel().GetByName(th.BasicTeam.Id, "off-topic", true)
|
||||
require.NoError(t, err)
|
||||
offTopicChannelID := channel.Id
|
||||
users, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelID)
|
||||
offTopicChannelId := channel.Id
|
||||
users, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)
|
||||
require.NoError(t, nErr)
|
||||
initialNumTownSquareUsers := len(users)
|
||||
|
||||
@@ -307,13 +307,13 @@ func TestJoinDefaultChannelsCreatesChannelMemberHistoryRecordOffTopic(t *testing
|
||||
th.App.JoinDefaultChannels(th.BasicTeam.Id, user, false, "")
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
histories, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelID)
|
||||
histories, nErr := th.App.Srv().Store.ChannelMemberHistory().GetUsersInChannelDuring(model.GetMillis()-100, model.GetMillis()+100, offTopicChannelId)
|
||||
require.NoError(t, nErr)
|
||||
assert.Len(t, histories, initialNumTownSquareUsers+1)
|
||||
|
||||
found := false
|
||||
for _, history := range histories {
|
||||
if user.Id == history.UserId && offTopicChannelID == history.ChannelId {
|
||||
if user.Id == history.UserId && offTopicChannelId == history.ChannelId {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@@ -440,15 +440,15 @@ func TestCreateDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
require.NoError(t, nErr)
|
||||
assert.Len(t, histories, 2)
|
||||
|
||||
historyID0 := histories[0].UserId
|
||||
historyID1 := histories[1].UserId
|
||||
switch historyID0 {
|
||||
historyId0 := histories[0].UserId
|
||||
historyId1 := histories[1].UserId
|
||||
switch historyId0 {
|
||||
case user1.Id:
|
||||
assert.Equal(t, user2.Id, historyID1)
|
||||
assert.Equal(t, user2.Id, historyId1)
|
||||
case user2.Id:
|
||||
assert.Equal(t, user1.Id, historyID1)
|
||||
assert.Equal(t, user1.Id, historyId1)
|
||||
default:
|
||||
require.Fail(t, "Unexpected user id in ChannelMemberHistory table", historyID0)
|
||||
require.Fail(t, "Unexpected user id in ChannelMemberHistory table", historyId0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,15 +468,15 @@ func TestGetDirectChannelCreatesChannelMemberHistoryRecord(t *testing.T) {
|
||||
require.NoError(t, nErr)
|
||||
assert.Len(t, histories, 2)
|
||||
|
||||
historyID0 := histories[0].UserId
|
||||
historyID1 := histories[1].UserId
|
||||
switch historyID0 {
|
||||
historyId0 := histories[0].UserId
|
||||
historyId1 := histories[1].UserId
|
||||
switch historyId0 {
|
||||
case user1.Id:
|
||||
assert.Equal(t, user2.Id, historyID1)
|
||||
assert.Equal(t, user2.Id, historyId1)
|
||||
case user2.Id:
|
||||
assert.Equal(t, user1.Id, historyID1)
|
||||
assert.Equal(t, user1.Id, historyId1)
|
||||
default:
|
||||
require.Fail(t, "Unexpected user id in ChannelMemberHistory table", historyID0)
|
||||
require.Fail(t, "Unexpected user id in ChannelMemberHistory table", historyId0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,9 +581,9 @@ func TestAddChannelMemberNoUserRequestor(t *testing.T) {
|
||||
groupUserIds = append(groupUserIds, user.Id)
|
||||
|
||||
channel := th.createChannel(th.BasicTeam, model.CHANNEL_OPEN)
|
||||
userRequestorID := ""
|
||||
postRootID := ""
|
||||
_, err = th.App.AddChannelMember(user.Id, channel, userRequestorID, postRootID)
|
||||
userRequestorId := ""
|
||||
postRootId := ""
|
||||
_, err = th.App.AddChannelMember(user.Id, channel, userRequestorId, postRootId)
|
||||
require.Nil(t, err, "Failed to add user to channel.")
|
||||
|
||||
// there should be a ChannelMemberHistory record for the user
|
||||
@@ -692,11 +692,11 @@ func TestFillInChannelProps(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
defer th.App.PermanentDeleteChannel(channelPrivate)
|
||||
|
||||
otherTeamID := model.NewId()
|
||||
otherTeamId := model.NewId()
|
||||
otherTeam := &model.Team{
|
||||
DisplayName: "dn_" + otherTeamID,
|
||||
Name: "name" + otherTeamID,
|
||||
Email: "success+" + otherTeamID + "@simulator.amazonses.com",
|
||||
DisplayName: "dn_" + otherTeamId,
|
||||
Name: "name" + otherTeamId,
|
||||
Email: "success+" + otherTeamId + "@simulator.amazonses.com",
|
||||
Type: model.TEAM_OPEN,
|
||||
}
|
||||
otherTeam, err = th.App.CreateTeam(otherTeam)
|
||||
@@ -952,9 +952,9 @@ func TestGetChannelMembersTimezones(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
userRequestorID := ""
|
||||
postRootID := ""
|
||||
_, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorID, postRootID)
|
||||
userRequestorId := ""
|
||||
postRootId := ""
|
||||
_, err := th.App.AddChannelMember(th.BasicUser2.Id, th.BasicChannel, userRequestorId, postRootId)
|
||||
require.Nil(t, err, "Failed to add user to channel.")
|
||||
|
||||
user := th.BasicUser
|
||||
|
||||
@@ -191,19 +191,19 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
|
||||
}
|
||||
trigger = strings.TrimPrefix(trigger, "/")
|
||||
|
||||
clientTriggerID, triggerID, appErr := model.GenerateTriggerId(args.UserId, a.AsymmetricSigningKey())
|
||||
clientTriggerId, triggerId, appErr := model.GenerateTriggerId(args.UserId, a.AsymmetricSigningKey())
|
||||
if appErr != nil {
|
||||
mlog.Warn("error occurred in generating trigger Id for a user ", mlog.Err(appErr))
|
||||
}
|
||||
|
||||
args.TriggerId = triggerID
|
||||
args.TriggerId = triggerId
|
||||
|
||||
// Plugins can override built in and custom commands
|
||||
cmd, response, appErr := a.tryExecutePluginCommand(args)
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
} else if cmd != nil && response != nil {
|
||||
response.TriggerId = clientTriggerID
|
||||
response.TriggerId = clientTriggerId
|
||||
return a.HandleCommandResponse(cmd, args, response, true)
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
} else if cmd != nil && response != nil {
|
||||
response.TriggerId = clientTriggerID
|
||||
response.TriggerId = clientTriggerId
|
||||
return a.HandleCommandResponse(cmd, args, response, false)
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
|
||||
func (a *App) MentionsToTeamMembers(message, teamID string) model.UserMentionMap {
|
||||
type mentionMapItem struct {
|
||||
Name string
|
||||
ID string
|
||||
Id string
|
||||
}
|
||||
|
||||
possibleMentions := model.PossibleAtMentions(message)
|
||||
@@ -290,7 +290,7 @@ func (a *App) MentionsToTeamMembers(message, teamID string) model.UserMentionMap
|
||||
|
||||
atMentionMap := make(model.UserMentionMap)
|
||||
for mention := range mentionChan {
|
||||
atMentionMap[mention.Name] = mention.ID
|
||||
atMentionMap[mention.Name] = mention.Id
|
||||
}
|
||||
|
||||
return atMentionMap
|
||||
@@ -301,7 +301,7 @@ func (a *App) MentionsToTeamMembers(message, teamID string) model.UserMentionMap
|
||||
func (a *App) MentionsToPublicChannels(message, teamID string) model.ChannelMentionMap {
|
||||
type mentionMapItem struct {
|
||||
Name string
|
||||
ID string
|
||||
Id string
|
||||
}
|
||||
|
||||
channelMentions := model.ChannelMentions(message)
|
||||
@@ -330,7 +330,7 @@ func (a *App) MentionsToPublicChannels(message, teamID string) model.ChannelMent
|
||||
|
||||
channelMentionMap := make(model.ChannelMentionMap)
|
||||
for mention := range mentionChan {
|
||||
channelMentionMap[mention.Name] = mention.ID
|
||||
channelMentionMap[mention.Name] = mention.Id
|
||||
}
|
||||
|
||||
return channelMentionMap
|
||||
|
||||
@@ -31,8 +31,8 @@ func TestConfigListener(t *testing.T) {
|
||||
|
||||
listenerCalled = true
|
||||
}
|
||||
listenerID := th.App.AddConfigListener(listener)
|
||||
defer th.App.RemoveConfigListener(listenerID)
|
||||
listenerId := th.App.AddConfigListener(listener)
|
||||
defer th.App.RemoveConfigListener(listenerId)
|
||||
|
||||
listener2Called := false
|
||||
listener2 := func(oldConfig *model.Config, newConfig *model.Config) {
|
||||
|
||||
@@ -166,9 +166,9 @@ func (a *App) exportVersion(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) exportAllTeams(writer io.Writer) *model.AppError {
|
||||
afterID := strings.Repeat("0", 26)
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
teams, err := a.Srv().Store.Team().GetAllForExportAfter(1000, afterID)
|
||||
teams, err := a.Srv().Store.Team().GetAllForExportAfter(1000, afterId)
|
||||
if err != nil {
|
||||
return model.NewAppError("exportAllTeams", "app.team.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func (a *App) exportAllTeams(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
for _, team := range teams {
|
||||
afterID = team.Id
|
||||
afterId = team.Id
|
||||
|
||||
// Skip deleted.
|
||||
if team.DeleteAt != 0 {
|
||||
@@ -196,9 +196,9 @@ func (a *App) exportAllTeams(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) exportAllChannels(writer io.Writer) *model.AppError {
|
||||
afterID := strings.Repeat("0", 26)
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
channels, err := a.Srv().Store.Channel().GetAllChannelsForExportAfter(1000, afterID)
|
||||
channels, err := a.Srv().Store.Channel().GetAllChannelsForExportAfter(1000, afterId)
|
||||
|
||||
if err != nil {
|
||||
return model.NewAppError("exportAllChannels", "app.channel.get_all.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -209,7 +209,7 @@ func (a *App) exportAllChannels(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
for _, channel := range channels {
|
||||
afterID = channel.Id
|
||||
afterId = channel.Id
|
||||
|
||||
// Skip deleted.
|
||||
if channel.DeleteAt != 0 {
|
||||
@@ -227,9 +227,9 @@ func (a *App) exportAllChannels(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
func (a *App) exportAllUsers(writer io.Writer) *model.AppError {
|
||||
afterID := strings.Repeat("0", 26)
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
users, err := a.Srv().Store.User().GetAllAfter(1000, afterID)
|
||||
users, err := a.Srv().Store.User().GetAllAfter(1000, afterId)
|
||||
|
||||
if err != nil {
|
||||
return model.NewAppError("exportAllUsers", "app.user.get.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -240,7 +240,7 @@ func (a *App) exportAllUsers(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
afterID = user.Id
|
||||
afterId = user.Id
|
||||
|
||||
// Gathering here the exportable preferences to pass them on to ImportLineFromUser
|
||||
exportedPrefs := make(map[string]*string)
|
||||
@@ -381,10 +381,10 @@ func (a *App) buildUserNotifyProps(notifyProps model.StringMap) *UserNotifyProps
|
||||
|
||||
func (a *App) exportAllPosts(writer io.Writer, withAttachments bool) ([]AttachmentImportData, *model.AppError) {
|
||||
var attachments []AttachmentImportData
|
||||
afterID := strings.Repeat("0", 26)
|
||||
afterId := strings.Repeat("0", 26)
|
||||
|
||||
for {
|
||||
posts, nErr := a.Srv().Store.Post().GetParentsForExportAfter(1000, afterID)
|
||||
posts, nErr := a.Srv().Store.Post().GetParentsForExportAfter(1000, afterId)
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("exportAllPosts", "app.post.get_posts.app_error", nil, nErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -394,7 +394,7 @@ func (a *App) exportAllPosts(writer io.Writer, withAttachments bool) ([]Attachme
|
||||
}
|
||||
|
||||
for _, post := range posts {
|
||||
afterID = post.Id
|
||||
afterId = post.Id
|
||||
|
||||
// Skip deleted.
|
||||
if post.DeleteAt != 0 {
|
||||
@@ -562,14 +562,14 @@ func (a *App) exportCustomEmoji(writer io.Writer, outPath, exportDir string, exp
|
||||
}
|
||||
|
||||
// Copies emoji files from 'data/emoji' dir to 'exported_emoji' dir
|
||||
func (a *App) copyEmojiImages(emojiID string, emojiImagePath string, pathToDir string) error {
|
||||
func (a *App) copyEmojiImages(emojiId string, emojiImagePath string, pathToDir string) error {
|
||||
fromPath, err := os.Open(emojiImagePath)
|
||||
if fromPath == nil || err != nil {
|
||||
return errors.New("Error reading " + emojiImagePath + "file")
|
||||
}
|
||||
defer fromPath.Close()
|
||||
|
||||
emojiDir := pathToDir + "/" + emojiID
|
||||
emojiDir := pathToDir + "/" + emojiId
|
||||
|
||||
if _, err = os.Stat(emojiDir); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
@@ -596,9 +596,9 @@ func (a *App) copyEmojiImages(emojiID string, emojiImagePath string, pathToDir s
|
||||
}
|
||||
|
||||
func (a *App) exportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
afterID := strings.Repeat("0", 26)
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
channels, err := a.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterID)
|
||||
channels, err := a.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, afterId)
|
||||
if err != nil {
|
||||
return model.NewAppError("exportAllDirectChannels", "app.channel.get_all_direct.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -608,7 +608,7 @@ func (a *App) exportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
}
|
||||
|
||||
for _, channel := range channels {
|
||||
afterID = channel.Id
|
||||
afterId = channel.Id
|
||||
|
||||
// Skip deleted.
|
||||
if channel.DeleteAt != 0 {
|
||||
@@ -627,9 +627,9 @@ func (a *App) exportAllDirectChannels(writer io.Writer) *model.AppError {
|
||||
|
||||
func (a *App) exportAllDirectPosts(writer io.Writer, withAttachments bool) ([]AttachmentImportData, *model.AppError) {
|
||||
var attachments []AttachmentImportData
|
||||
afterID := strings.Repeat("0", 26)
|
||||
afterId := strings.Repeat("0", 26)
|
||||
for {
|
||||
posts, err := a.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, afterID)
|
||||
posts, err := a.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, afterId)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("exportAllDirectPosts", "app.post.get_direct_posts.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -639,7 +639,7 @@ func (a *App) exportAllDirectPosts(writer io.Writer, withAttachments bool) ([]At
|
||||
}
|
||||
|
||||
for _, post := range posts {
|
||||
afterID = post.Id
|
||||
afterId = post.Id
|
||||
|
||||
// Skip deleted.
|
||||
if post.DeleteAt != 0 {
|
||||
|
||||
12
app/file.go
12
app/file.go
@@ -253,9 +253,9 @@ func (a *App) RemoveDirectory(path string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) getInfoForFilename(post *model.Post, teamID, channelID, userID, oldID, filename string) *model.FileInfo {
|
||||
func (a *App) getInfoForFilename(post *model.Post, teamID, channelID, userID, oldId, filename string) *model.FileInfo {
|
||||
name, _ := url.QueryUnescape(filename)
|
||||
pathPrefix := fmt.Sprintf("teams/%s/channels/%s/users/%s/%s/", teamID, channelID, userID, oldID)
|
||||
pathPrefix := fmt.Sprintf("teams/%s/channels/%s/users/%s/%s/", teamID, channelID, userID, oldId)
|
||||
path := pathPrefix + name
|
||||
|
||||
// Open the file and populate the fields of the FileInfo
|
||||
@@ -959,11 +959,11 @@ func (t UploadFileTask) newAppError(id string, httpStatus int, extra ...interfac
|
||||
return model.NewAppError("uploadFileTask", id, params, "", httpStatus)
|
||||
}
|
||||
|
||||
func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamID string, rawChannelID string, rawUserID string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError) {
|
||||
func (a *App) DoUploadFileExpectModification(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError) {
|
||||
filename := filepath.Base(rawFilename)
|
||||
teamID := filepath.Base(rawTeamID)
|
||||
channelID := filepath.Base(rawChannelID)
|
||||
userID := filepath.Base(rawUserID)
|
||||
teamID := filepath.Base(rawTeamId)
|
||||
channelID := filepath.Base(rawChannelId)
|
||||
userID := filepath.Base(rawUserId)
|
||||
|
||||
info, err := model.GetInfoForBytes(filename, bytes.NewReader(data), len(data))
|
||||
if err != nil {
|
||||
|
||||
@@ -79,7 +79,7 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
{fmt.Sprintf("zero-%dMb", mb(len(zero10M))), ".zero", zero10M},
|
||||
}
|
||||
|
||||
fileBenchmarks := []struct {
|
||||
file_benchmarks := []struct {
|
||||
title string
|
||||
f func(b *testing.B, n int, data []byte, ext string)
|
||||
}{
|
||||
@@ -184,7 +184,7 @@ func BenchmarkUploadFile(b *testing.B) {
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
for _, fb := range fileBenchmarks {
|
||||
for _, fb := range file_benchmarks {
|
||||
b.Run(file.title+"-"+fb.title, func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
fb.f(b, i, file.data, file.ext)
|
||||
|
||||
@@ -65,7 +65,7 @@ func (a *App) GetGroupsBySource(groupSource model.GroupSource) ([]*model.Group,
|
||||
return groups, nil
|
||||
}
|
||||
|
||||
func (a *App) GetGroupsByUserID(userID string) ([]*model.Group, *model.AppError) {
|
||||
func (a *App) GetGroupsByUserId(userID string) ([]*model.Group, *model.AppError) {
|
||||
groups, err := a.Srv().Store.Group().GetByUser(userID)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetGroupsByUserId", "app.select_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -2625,7 +2625,7 @@ func (a *OpenTracingAppLayer) DeleteAllKeysForPlugin(pluginID string) *model.App
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) DeleteBotIconImage(botUserID string) *model.AppError {
|
||||
func (a *OpenTracingAppLayer) DeleteBotIconImage(botUserId string) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DeleteBotIconImage")
|
||||
|
||||
@@ -2637,7 +2637,7 @@ func (a *OpenTracingAppLayer) DeleteBotIconImage(botUserID string) *model.AppErr
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.DeleteBotIconImage(botUserID)
|
||||
resultVar0 := a.app.DeleteBotIconImage(botUserId)
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
@@ -3493,7 +3493,7 @@ func (a *OpenTracingAppLayer) DoUploadFile(now time.Time, rawTeamId string, rawC
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) DoUploadFileExpectModification(now time.Time, rawTeamID string, rawChannelID string, rawUserID string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) DoUploadFileExpectModification(now time.Time, rawTeamId string, rawChannelId string, rawUserId string, rawFilename string, data []byte) (*model.FileInfo, []byte, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.DoUploadFileExpectModification")
|
||||
|
||||
@@ -3505,7 +3505,7 @@ func (a *OpenTracingAppLayer) DoUploadFileExpectModification(now time.Time, rawT
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1, resultVar2 := a.app.DoUploadFileExpectModification(now, rawTeamID, rawChannelID, rawUserID, rawFilename, data)
|
||||
resultVar0, resultVar1, resultVar2 := a.app.DoUploadFileExpectModification(now, rawTeamId, rawChannelId, rawUserId, rawFilename, data)
|
||||
|
||||
if resultVar2 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar2))
|
||||
@@ -4455,7 +4455,7 @@ func (a *OpenTracingAppLayer) GetAuthorizedAppsForUser(userID string, page int,
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetBot(botUserID string, includeDeleted bool) (*model.Bot, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetBot(botUserId string, includeDeleted bool) (*model.Bot, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetBot")
|
||||
|
||||
@@ -4467,7 +4467,7 @@ func (a *OpenTracingAppLayer) GetBot(botUserID string, includeDeleted bool) (*mo
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetBot(botUserID, includeDeleted)
|
||||
resultVar0, resultVar1 := a.app.GetBot(botUserId, includeDeleted)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -4477,7 +4477,7 @@ func (a *OpenTracingAppLayer) GetBot(botUserID string, includeDeleted bool) (*mo
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetBotIconImage(botUserID string) ([]byte, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetBotIconImage(botUserId string) ([]byte, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetBotIconImage")
|
||||
|
||||
@@ -4489,7 +4489,7 @@ func (a *OpenTracingAppLayer) GetBotIconImage(botUserID string) ([]byte, *model.
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetBotIconImage(botUserID)
|
||||
resultVar0, resultVar1 := a.app.GetBotIconImage(botUserId)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -5975,9 +5975,9 @@ func (a *OpenTracingAppLayer) GetGroupsByTeam(teamID string, opts model.GroupSea
|
||||
return resultVar0, resultVar1, resultVar2
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetGroupsByUserID(userID string) ([]*model.Group, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetGroupsByUserId(userID string) ([]*model.Group, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetGroupsByUserID")
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetGroupsByUserId")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
@@ -5987,7 +5987,7 @@ func (a *OpenTracingAppLayer) GetGroupsByUserID(userID string) ([]*model.Group,
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetGroupsByUserID(userID)
|
||||
resultVar0, resultVar1 := a.app.GetGroupsByUserId(userID)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -11006,7 +11006,7 @@ func (a *OpenTracingAppLayer) OverrideIconURLIfEmoji(post *model.Post) {
|
||||
a.app.OverrideIconURLIfEmoji(post)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) PatchBot(botUserID string, botPatch *model.BotPatch) (*model.Bot, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) PatchBot(botUserId string, botPatch *model.BotPatch) (*model.Bot, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PatchBot")
|
||||
|
||||
@@ -11018,7 +11018,7 @@ func (a *OpenTracingAppLayer) PatchBot(botUserID string, botPatch *model.BotPatc
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.PatchBot(botUserID, botPatch)
|
||||
resultVar0, resultVar1 := a.app.PatchBot(botUserId, botPatch)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -11204,7 +11204,7 @@ func (a *OpenTracingAppLayer) PermanentDeleteAllUsers() *model.AppError {
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) PermanentDeleteBot(botUserID string) *model.AppError {
|
||||
func (a *OpenTracingAppLayer) PermanentDeleteBot(botUserId string) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.PermanentDeleteBot")
|
||||
|
||||
@@ -11216,7 +11216,7 @@ func (a *OpenTracingAppLayer) PermanentDeleteBot(botUserID string) *model.AppErr
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.PermanentDeleteBot(botUserID)
|
||||
resultVar0 := a.app.PermanentDeleteBot(botUserId)
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
@@ -13784,7 +13784,7 @@ func (a *OpenTracingAppLayer) SetAutoResponderStatus(user *model.User, oldNotify
|
||||
a.app.SetAutoResponderStatus(user, oldNotifyProps)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SetBotIconImage(botUserID string, file io.ReadSeeker) *model.AppError {
|
||||
func (a *OpenTracingAppLayer) SetBotIconImage(botUserId string, file io.ReadSeeker) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetBotIconImage")
|
||||
|
||||
@@ -13796,7 +13796,7 @@ func (a *OpenTracingAppLayer) SetBotIconImage(botUserID string, file io.ReadSeek
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.SetBotIconImage(botUserID, file)
|
||||
resultVar0 := a.app.SetBotIconImage(botUserId, file)
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
@@ -13806,7 +13806,7 @@ func (a *OpenTracingAppLayer) SetBotIconImage(botUserID string, file io.ReadSeek
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) SetBotIconImageFromMultiPartFile(botUserID string, imageData *multipart.FileHeader) *model.AppError {
|
||||
func (a *OpenTracingAppLayer) SetBotIconImageFromMultiPartFile(botUserId string, imageData *multipart.FileHeader) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.SetBotIconImageFromMultiPartFile")
|
||||
|
||||
@@ -13818,7 +13818,7 @@ func (a *OpenTracingAppLayer) SetBotIconImageFromMultiPartFile(botUserID string,
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.SetBotIconImageFromMultiPartFile(botUserID, imageData)
|
||||
resultVar0 := a.app.SetBotIconImageFromMultiPartFile(botUserId, imageData)
|
||||
|
||||
if resultVar0 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar0))
|
||||
@@ -14813,7 +14813,7 @@ func (a *OpenTracingAppLayer) UpdateActive(user *model.User, active bool) (*mode
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) UpdateBotActive(botUserID string, active bool) (*model.Bot, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) UpdateBotActive(botUserId string, active bool) (*model.Bot, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UpdateBotActive")
|
||||
|
||||
@@ -14825,7 +14825,7 @@ func (a *OpenTracingAppLayer) UpdateBotActive(botUserID string, active bool) (*m
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.UpdateBotActive(botUserID, active)
|
||||
resultVar0, resultVar1 := a.app.UpdateBotActive(botUserId, active)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -14835,7 +14835,7 @@ func (a *OpenTracingAppLayer) UpdateBotActive(botUserID string, active bool) (*m
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) UpdateBotOwner(botUserID string, newOwnerID string) (*model.Bot, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) UpdateBotOwner(botUserId string, newOwnerId string) (*model.Bot, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.UpdateBotOwner")
|
||||
|
||||
@@ -14847,7 +14847,7 @@ func (a *OpenTracingAppLayer) UpdateBotOwner(botUserID string, newOwnerID string
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.UpdateBotOwner(botUserID, newOwnerID)
|
||||
resultVar0, resultVar1 := a.app.UpdateBotOwner(botUserId, newOwnerId)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
|
||||
@@ -537,7 +537,7 @@ func (api *PluginAPI) GetGroupByName(name string) (*model.Group, *model.AppError
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetGroupsForUser(userID string) ([]*model.Group, *model.AppError) {
|
||||
return api.app.GetGroupsByUserID(userID)
|
||||
return api.app.GetGroupsByUserId(userID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
|
||||
|
||||
Ссылка в новой задаче
Block a user