Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
2.2 KiB
Go
75 lines
2.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package api4
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateScheduledPost(t *testing.T) {
|
|
mainHelper.Parallel(t)
|
|
th := Setup(t).InitBasic()
|
|
defer th.TearDown()
|
|
|
|
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
|
|
|
|
client := th.Client
|
|
|
|
t.Run("base case", func(t *testing.T) {
|
|
userId := model.NewId()
|
|
|
|
scheduledPost := &model.ScheduledPost{
|
|
Draft: model.Draft{
|
|
CreateAt: model.GetMillis(),
|
|
UserId: userId,
|
|
ChannelId: th.BasicChannel.Id,
|
|
Message: "this is a scheduled post",
|
|
},
|
|
ScheduledAt: model.GetMillis() + 100000, // 100 seconds in the future
|
|
}
|
|
createdScheduledPost, _, err := client.CreateScheduledPost(context.Background(), scheduledPost)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, createdScheduledPost)
|
|
})
|
|
|
|
t.Run("should not allow created scheduled post in read-only channel", func(t *testing.T) {
|
|
channel := th.CreatePublicChannel()
|
|
th.AddUserToChannel(th.BasicUser, channel)
|
|
|
|
channelModerationPatches := []*model.ChannelModerationPatch{
|
|
{
|
|
Name: model.NewPointer(model.PermissionCreatePost.Id),
|
|
Roles: &model.ChannelModeratedRolesPatch{
|
|
Guests: model.NewPointer(true),
|
|
Members: model.NewPointer(false),
|
|
},
|
|
},
|
|
}
|
|
|
|
err := th.App.SetPhase2PermissionsMigrationStatus(true)
|
|
require.NoError(t, err)
|
|
|
|
_, appErr := th.App.PatchChannelModerationsForChannel(th.Context, channel, channelModerationPatches)
|
|
require.Nil(t, appErr)
|
|
|
|
scheduledPost := &model.ScheduledPost{
|
|
Draft: model.Draft{
|
|
CreateAt: model.GetMillis(),
|
|
UserId: th.BasicUser.Id,
|
|
ChannelId: channel.Id,
|
|
Message: "this is a scheduled post",
|
|
},
|
|
ScheduledAt: model.GetMillis() + 100000, // 100 seconds in the future
|
|
}
|
|
createdScheduledPost, _, httpErr := client.CreateScheduledPost(context.Background(), scheduledPost)
|
|
require.Error(t, httpErr)
|
|
require.Contains(t, httpErr.Error(), "You do not have the appropriate permissions.")
|
|
require.Nil(t, createdScheduledPost)
|
|
})
|
|
}
|