api

package
v3.7.5+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2017 License: AGPL-3.0, Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USER_PASSWORD              = "passwd"
	CHANNEL_TYPE               = model.CHANNEL_OPEN
	FUZZ_USER_EMAIL_PREFIX_LEN = 10
	BTEST_TEAM_DISPLAY_NAME    = "TestTeam"
	BTEST_TEAM_NAME            = "z-z-testdomaina"
	BTEST_TEAM_EMAIL           = "test@nowhere.com"
	BTEST_TEAM_TYPE            = model.TEAM_OPEN
	BTEST_USER_NAME            = "Mr. Testing Tester"
	BTEST_USER_EMAIL           = "success+ttester@simulator.amazonses.com"
	BTEST_USER_PASSWORD        = "passwd"
)
View Source
const (
	CMD_EXPAND   = "expand"
	CMD_COLLAPSE = "collapse"
)
View Source
const (
	MaxEmojiFileSize = 1000 * 1024 // 1 MB
	MaxEmojiWidth    = 128
	MaxEmojiHeight   = 128
)
View Source
const (
	CMD_AWAY = "away"
)
View Source
const (
	CMD_ECHO = "echo"
)
View Source
const (
	CMD_INVITE_PEOPLE = "invite_people"
)
View Source
const (
	CMD_JOIN = "join"
)
View Source
const (
	CMD_LOADTEST = "loadtest"
)
View Source
const (
	CMD_LOGOUT = "logout"
)
View Source
const (
	CMD_ME = "me"
)
View Source
const (
	CMD_MSG = "msg"
)
View Source
const (
	CMD_OFFLINE = "offline"
)
View Source
const (
	CMD_ONLINE = "online"
)
View Source
const (
	CMD_SHORTCUTS = "shortcuts"
)
View Source
const (
	CMD_SHRUG = "shrug"
)
View Source
const OPEN_GRAPH_METADATA_CACHE_SIZE = 10000

Variables

View Source
var (
	TEAM_NAME_LEN            = utils.Range{Begin: 10, End: 20}
	TEAM_DOMAIN_NAME_LEN     = utils.Range{Begin: 10, End: 20}
	TEAM_EMAIL_LEN           = utils.Range{Begin: 15, End: 30}
	USER_NAME_LEN            = utils.Range{Begin: 5, End: 20}
	USER_EMAIL_LEN           = utils.Range{Begin: 15, End: 30}
	CHANNEL_DISPLAY_NAME_LEN = utils.Range{Begin: 10, End: 20}
	CHANNEL_NAME_LEN         = utils.Range{Begin: 5, End: 20}
	POST_MESSAGE_LEN         = utils.Range{Begin: 100, End: 400}
	POST_HASHTAGS_NUM        = utils.Range{Begin: 5, End: 10}
	POST_MENTIONS_NUM        = utils.Range{Begin: 0, End: 3}
	TEST_IMAGE_FILENAMES     = []string{"test.png", "testjpg.jpg", "testgif.gif"}
)

Functions

func ApiAdminSystemRequired

func ApiAdminSystemRequired(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiAdminSystemRequiredTrustRequester

func ApiAdminSystemRequiredTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiAppHandler

func ApiAppHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiAppHandlerTrustRequester

func ApiAppHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiAppHandlerTrustRequesterIndependent

func ApiAppHandlerTrustRequesterIndependent(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiUserRequired

func ApiUserRequired(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiUserRequiredActivity

func ApiUserRequiredActivity(h func(*Context, http.ResponseWriter, *http.Request), isUserActivity bool) http.Handler

func ApiUserRequiredMfa

func ApiUserRequiredMfa(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiUserRequiredTrustRequester

func ApiUserRequiredTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func ApiWebSocketHandler

func ApiWebSocketHandler(wh func(*model.WebSocketRequest) (map[string]interface{}, *model.AppError)) webSocketHandler

func AppHandler

func AppHandler(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func AppHandlerIndependent

func AppHandlerIndependent(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func AppHandlerTrustRequester

func AppHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

func AuthorizeOAuthUser

func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser, string, map[string]string, *model.AppError)

func CanManageChannel

func CanManageChannel(c *Context, channel *model.Channel) bool

func CompleteSwitchWithOAuth added in v1.4.0

func CompleteSwitchWithOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.ReadCloser, email string)

func CreateBasicUser

func CreateBasicUser(client *model.Client) *model.AppError

Basic test team and user so you always know one

func GetAllTeamListings

func GetAllTeamListings(c *Context, w http.ResponseWriter, r *http.Request)

func GetAuthData

func GetAuthData(code string) *model.AuthData

func GetAuthorizationCode

func GetAuthorizationCode(c *Context, service string, props map[string]string, loginHint string) (string, *model.AppError)

func Handle404

func Handle404(w http.ResponseWriter, r *http.Request)

func HandleEtag

func HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool

func InitAdmin

func InitAdmin()

func InitApi

func InitApi()

func InitChannel

func InitChannel()

func InitCommand

func InitCommand()

func InitDeprecated

func InitDeprecated()

func InitEmoji

func InitEmoji()

func InitFile

func InitFile()

func InitGeneral

func InitGeneral()

func InitLicense

func InitLicense()

func InitOAuth

func InitOAuth()

func InitPost

func InitPost()

func InitPreference added in v1.2.1

func InitPreference()

func InitReaction

func InitReaction()

func InitRouter

func InitRouter()

func InitStatus

func InitStatus()

func InitTeam

func InitTeam()

func InitUser

func InitUser()

func InitWebSocket

func InitWebSocket()

func InitWebhook

func InitWebhook()

func InitWebrtc

func InitWebrtc()

func IsApiCall

func IsApiCall(r *http.Request) bool

func LinkUserToTeam

func LinkUserToTeam(user *model.User, team *model.Team)

func LoginByOAuth added in v1.4.0

func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service string, userData io.Reader) *model.User

func Logout

func Logout(c *Context, w http.ResponseWriter, r *http.Request)

func MakeUserChannelAdmin

func MakeUserChannelAdmin(user *model.User, channel *model.Channel)

func MakeUserChannelUser

func MakeUserChannelUser(user *model.User, channel *model.Channel)

func NewInvalidParamError

func NewInvalidParamError(where string, name string) *model.AppError

func NewInvalidWebSocketParamError

func NewInvalidWebSocketParamError(action string, name string) *model.AppError

func RegisterCommandProvider

func RegisterCommandProvider(newProvider CommandProvider)

func RenderWebError

func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request)

func ReturnStatusOK

func ReturnStatusOK(w http.ResponseWriter)

func TearDown

func TearDown()

func UpdateUserToNonTeamAdmin

func UpdateUserToNonTeamAdmin(user *model.User, team *model.Team)

func UpdateUserToTeamAdmin

func UpdateUserToTeamAdmin(user *model.User, team *model.Team)

func UserRequired

func UserRequired(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler

Types

type AutoChannelCreator

type AutoChannelCreator struct {
	Fuzzy              bool
	DisplayNameLen     utils.Range
	DisplayNameCharset string
	NameLen            utils.Range
	NameCharset        string
	ChannelType        string
	// contains filtered or unexported fields
}

func NewAutoChannelCreator

func NewAutoChannelCreator(client *model.Client, team *model.Team) *AutoChannelCreator

func (*AutoChannelCreator) CreateTestChannels

func (cfg *AutoChannelCreator) CreateTestChannels(num utils.Range) ([]*model.Channel, bool)

type AutoPostCreator

type AutoPostCreator struct {
	Fuzzy          bool
	TextLength     utils.Range
	HasImage       bool
	ImageFilenames []string
	Users          []string
	Mentions       utils.Range
	Tags           utils.Range
	// contains filtered or unexported fields
}

func NewAutoPostCreator

func NewAutoPostCreator(client *model.Client, channelid string) *AutoPostCreator

Automatic poster used for testing

func (*AutoPostCreator) CreateRandomPost

func (cfg *AutoPostCreator) CreateRandomPost() (*model.Post, bool)

func (*AutoPostCreator) CreateTestPosts

func (cfg *AutoPostCreator) CreateTestPosts(rangePosts utils.Range) ([]*model.Post, bool)

func (*AutoPostCreator) UploadTestFile

func (cfg *AutoPostCreator) UploadTestFile() ([]string, bool)

type AutoTeamCreator

type AutoTeamCreator struct {
	Fuzzy         bool
	NameLength    utils.Range
	NameCharset   string
	DomainLength  utils.Range
	DomainCharset string
	EmailLength   utils.Range
	EmailCharset  string
	// contains filtered or unexported fields
}

func NewAutoTeamCreator

func NewAutoTeamCreator(client *model.Client) *AutoTeamCreator

func (*AutoTeamCreator) CreateTestTeams

func (cfg *AutoTeamCreator) CreateTestTeams(num utils.Range) ([]*model.Team, bool)

type AutoUserCreator

type AutoUserCreator struct {
	EmailLength  utils.Range
	EmailCharset string
	NameLength   utils.Range
	NameCharset  string
	Fuzzy        bool
	// contains filtered or unexported fields
}

func NewAutoUserCreator

func NewAutoUserCreator(client *model.Client, team *model.Team) *AutoUserCreator

func (*AutoUserCreator) CreateTestUsers

func (cfg *AutoUserCreator) CreateTestUsers(num utils.Range) ([]*model.User, bool)

type AwayProvider

type AwayProvider struct {
}

func (*AwayProvider) DoCommand

func (me *AwayProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*AwayProvider) GetCommand

func (me *AwayProvider) GetCommand(c *Context) *model.Command

func (*AwayProvider) GetTrigger

func (me *AwayProvider) GetTrigger() string

type CollapseProvider

type CollapseProvider struct {
}

func (*CollapseProvider) DoCommand

func (me *CollapseProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*CollapseProvider) GetCommand

func (me *CollapseProvider) GetCommand(c *Context) *model.Command

func (*CollapseProvider) GetTrigger

func (me *CollapseProvider) GetTrigger() string

type CommandProvider

type CommandProvider interface {
	GetTrigger() string
	GetCommand(c *Context) *model.Command
	DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse
}

func GetCommandProvider

func GetCommandProvider(name string) CommandProvider

type Context

type Context struct {
	Session   model.Session
	RequestId string
	IpAddress string
	Path      string
	Err       *model.AppError

	T      goi18n.TranslateFunc
	Locale string
	TeamId string
	// contains filtered or unexported fields
}

func (*Context) CheckTeamId

func (c *Context) CheckTeamId()

func (*Context) GetCurrentTeamMember

func (c *Context) GetCurrentTeamMember() *model.TeamMember

func (*Context) GetSiteURL

func (c *Context) GetSiteURL() string

func (*Context) GetSiteURLHeader

func (c *Context) GetSiteURLHeader() string

func (*Context) GetTeamURL

func (c *Context) GetTeamURL() string

func (*Context) GetTeamURLFromTeam

func (c *Context) GetTeamURLFromTeam(team *model.Team) string

func (*Context) IsSystemAdmin

func (c *Context) IsSystemAdmin() bool

func (*Context) LogAudit

func (c *Context) LogAudit(extraInfo string)

func (*Context) LogAuditWithUserId

func (c *Context) LogAuditWithUserId(userId, extraInfo string)

func (*Context) LogDebug

func (c *Context) LogDebug(err *model.AppError)

func (*Context) LogError

func (c *Context) LogError(err *model.AppError)

func (*Context) MfaRequired

func (c *Context) MfaRequired()

func (*Context) RemoveSessionCookie

func (c *Context) RemoveSessionCookie(w http.ResponseWriter, r *http.Request)

func (*Context) SetInvalidParam

func (c *Context) SetInvalidParam(where string, name string)

func (*Context) SetPermissionError

func (c *Context) SetPermissionError(permission *model.Permission)

func (*Context) SetSiteURL

func (c *Context) SetSiteURL(url string)

func (*Context) SetSiteURLHeader

func (c *Context) SetSiteURLHeader(url string)

func (*Context) SetTeamURLFromSession added in v1.1.0

func (c *Context) SetTeamURLFromSession()

func (*Context) SetUnknownError

func (c *Context) SetUnknownError(where string, details string)

func (*Context) SystemAdminRequired

func (c *Context) SystemAdminRequired()

func (*Context) UserRequired

func (c *Context) UserRequired()

type EchoProvider

type EchoProvider struct {
}

func (*EchoProvider) DoCommand

func (me *EchoProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*EchoProvider) GetCommand

func (me *EchoProvider) GetCommand(c *Context) *model.Command

func (*EchoProvider) GetTrigger

func (me *EchoProvider) GetTrigger() string

type ExpandProvider

type ExpandProvider struct {
}

func (*ExpandProvider) DoCommand

func (me *ExpandProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*ExpandProvider) GetCommand

func (me *ExpandProvider) GetCommand(c *Context) *model.Command

func (*ExpandProvider) GetTrigger

func (me *ExpandProvider) GetTrigger() string

type InvitePeopleProvider

type InvitePeopleProvider struct {
}

func (*InvitePeopleProvider) DoCommand

func (me *InvitePeopleProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*InvitePeopleProvider) GetCommand

func (me *InvitePeopleProvider) GetCommand(c *Context) *model.Command

func (*InvitePeopleProvider) GetTrigger

func (me *InvitePeopleProvider) GetTrigger() string

type JoinProvider

type JoinProvider struct {
}

func (*JoinProvider) DoCommand

func (me *JoinProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*JoinProvider) GetCommand

func (me *JoinProvider) GetCommand(c *Context) *model.Command

func (*JoinProvider) GetTrigger

func (me *JoinProvider) GetTrigger() string

type LoadTestProvider

type LoadTestProvider struct {
}

func (*LoadTestProvider) ChannelsCommand

func (me *LoadTestProvider) ChannelsCommand(c *Context, channelId string, message string) *model.CommandResponse

func (*LoadTestProvider) DoCommand

func (me *LoadTestProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*LoadTestProvider) GetCommand

func (me *LoadTestProvider) GetCommand(c *Context) *model.Command

func (*LoadTestProvider) GetTrigger

func (me *LoadTestProvider) GetTrigger() string

func (*LoadTestProvider) HelpCommand

func (me *LoadTestProvider) HelpCommand(c *Context, channelId string, message string) *model.CommandResponse

func (*LoadTestProvider) JsonCommand

func (me *LoadTestProvider) JsonCommand(c *Context, channelId string, message string) *model.CommandResponse

func (*LoadTestProvider) PostsCommand

func (me *LoadTestProvider) PostsCommand(c *Context, channelId string, message string) *model.CommandResponse

func (*LoadTestProvider) SetupCommand

func (me *LoadTestProvider) SetupCommand(c *Context, channelId string, message string) *model.CommandResponse

func (*LoadTestProvider) UrlCommand

func (me *LoadTestProvider) UrlCommand(c *Context, channelId string, message string) *model.CommandResponse

func (*LoadTestProvider) UsersCommand

func (me *LoadTestProvider) UsersCommand(c *Context, channelId string, message string) *model.CommandResponse

type LogoutProvider

type LogoutProvider struct {
}

func (*LogoutProvider) DoCommand

func (me *LogoutProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*LogoutProvider) GetCommand

func (me *LogoutProvider) GetCommand(c *Context) *model.Command

func (*LogoutProvider) GetTrigger

func (me *LogoutProvider) GetTrigger() string

type MeProvider

type MeProvider struct {
}

func (*MeProvider) DoCommand

func (me *MeProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*MeProvider) GetCommand

func (me *MeProvider) GetCommand(c *Context) *model.Command

func (*MeProvider) GetTrigger

func (me *MeProvider) GetTrigger() string

type OfflineProvider

type OfflineProvider struct {
}

func (*OfflineProvider) DoCommand

func (me *OfflineProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*OfflineProvider) GetCommand

func (me *OfflineProvider) GetCommand(c *Context) *model.Command

func (*OfflineProvider) GetTrigger

func (me *OfflineProvider) GetTrigger() string

type OnlineProvider

type OnlineProvider struct {
}

func (*OnlineProvider) DoCommand

func (me *OnlineProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*OnlineProvider) GetCommand

func (me *OnlineProvider) GetCommand(c *Context) *model.Command

func (*OnlineProvider) GetTrigger

func (me *OnlineProvider) GetTrigger() string

type Routes

type Routes struct {
	Root    *mux.Router // ”
	ApiRoot *mux.Router // 'api/v3'

	Users    *mux.Router // 'api/v3/users'
	NeedUser *mux.Router // 'api/v3/users/{user_id:[A-Za-z0-9]+}'

	Teams    *mux.Router // 'api/v3/teams'
	NeedTeam *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}'

	Channels        *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/channels'
	NeedChannel     *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/channels/{channel_id:[A-Za-z0-9]+}'
	NeedChannelName *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/channels/name/{channel_name:[A-Za-z0-9_-]+}'

	Posts    *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/channels/{channel_id:[A-Za-z0-9]+}/posts'
	NeedPost *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/channels/{channel_id:[A-Za-z0-9]+}/posts/{post_id:[A-Za-z0-9]+}'

	Commands *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/commands'
	Hooks    *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks'

	TeamFiles *mux.Router // 'api/v3/teams/{team_id:[A-Za-z0-9]+}/files'
	Files     *mux.Router // 'api/v3/files'
	NeedFile  *mux.Router // 'api/v3/files/{file_id:[A-Za-z0-9]+}'

	OAuth *mux.Router // 'api/v3/oauth'

	Admin *mux.Router // 'api/v3/admin'

	General *mux.Router // 'api/v3/general'

	Preferences *mux.Router // 'api/v3/preferences'

	License *mux.Router // 'api/v3/license'

	Public *mux.Router // 'api/v3/public'

	Emoji *mux.Router // 'api/v3/emoji'

	Webrtc *mux.Router // 'api/v3/webrtc'
}
var BaseRoutes *Routes

type ShortcutsProvider

type ShortcutsProvider struct {
}

func (*ShortcutsProvider) DoCommand

func (me *ShortcutsProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*ShortcutsProvider) GetCommand

func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command

func (*ShortcutsProvider) GetTrigger

func (me *ShortcutsProvider) GetTrigger() string

type ShrugProvider

type ShrugProvider struct {
}

func (*ShrugProvider) DoCommand

func (me *ShrugProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse

func (*ShrugProvider) GetCommand

func (me *ShrugProvider) GetCommand(c *Context) *model.Command

func (*ShrugProvider) GetTrigger

func (me *ShrugProvider) GetTrigger() string

type TeamEnvironment added in v1.2.1

type TeamEnvironment struct {
	Users    []*model.User
	Channels []*model.Channel
}

func CreateTestEnvironmentInTeam added in v1.2.1

func CreateTestEnvironmentInTeam(client *model.Client, team *model.Team, rangeChannels utils.Range, rangeUsers utils.Range, rangePosts utils.Range, fuzzy bool) (TeamEnvironment, bool)

type TestEnvironment added in v1.2.1

type TestEnvironment struct {
	Teams        []*model.Team
	Environments []TeamEnvironment
}

func CreateTestEnvironmentWithTeams added in v1.2.1

func CreateTestEnvironmentWithTeams(client *model.Client, rangeTeams utils.Range, rangeChannels utils.Range, rangeUsers utils.Range, rangePosts utils.Range, fuzzy bool) (TestEnvironment, bool)

type TestHelper

type TestHelper struct {
	BasicClient  *model.Client
	BasicTeam    *model.Team
	BasicUser    *model.User
	BasicUser2   *model.User
	BasicChannel *model.Channel
	BasicPost    *model.Post

	SystemAdminClient  *model.Client
	SystemAdminTeam    *model.Team
	SystemAdminUser    *model.User
	SystemAdminChannel *model.Channel
}

func Setup

func Setup() *TestHelper

func SetupEnterprise

func SetupEnterprise() *TestHelper

func (*TestHelper) CreateChannel

func (me *TestHelper) CreateChannel(client *model.Client, team *model.Team) *model.Channel

func (*TestHelper) CreateClient

func (me *TestHelper) CreateClient() *model.Client

func (*TestHelper) CreatePost

func (me *TestHelper) CreatePost(client *model.Client, channel *model.Channel) *model.Post

func (*TestHelper) CreatePrivateChannel

func (me *TestHelper) CreatePrivateChannel(client *model.Client, team *model.Team) *model.Channel

func (*TestHelper) CreateTeam

func (me *TestHelper) CreateTeam(client *model.Client) *model.Team

func (*TestHelper) CreateUser

func (me *TestHelper) CreateUser(client *model.Client) *model.User

func (*TestHelper) CreateWebSocketClient

func (me *TestHelper) CreateWebSocketClient() (*model.WebSocketClient, *model.AppError)

func (*TestHelper) InitBasic

func (me *TestHelper) InitBasic() *TestHelper

func (*TestHelper) InitSystemAdmin

func (me *TestHelper) InitSystemAdmin() *TestHelper

func (*TestHelper) LoginBasic

func (me *TestHelper) LoginBasic()

func (*TestHelper) LoginBasic2

func (me *TestHelper) LoginBasic2()

func (*TestHelper) LoginSystemAdmin

func (me *TestHelper) LoginSystemAdmin()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL