plugin

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Client

type Client interface {
	GenerateOAuthToken(encodedFormValues url.Values) (*serializers.OAuthSuccessResponse, int, error)
	CreateTask(body *serializers.CreateTaskRequestPayload, mattermostUserID string) (*serializers.TaskValue, int, error)
	GetTask(organization, taskID, mattermostUserID string) (*serializers.TaskValue, int, error)
	Link(body *serializers.LinkRequestPayload, mattermostUserID string) (*serializers.Project, int, error)
	CreateSubscription(body *serializers.CreateSubscriptionRequestPayload, project *serializers.ProjectDetails, channelID, pluginURL, mattermostUserID string) (*serializers.SubscriptionValue, int, error)
	DeleteSubscription(organization, subscriptionID, mattermostUserID string) (int, error)
	CheckIfUserIsProjectAdmin(organizationName, projectID, pluginURL, mattermostUserID string) (int, error)
}

func InitClient

func InitClient(p *Plugin) Client

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func (*Handler) Handle

func (ch *Handler) Handle(p *Plugin, c *plugin.Context, commandArgs *model.CommandArgs, args ...string) (*model.CommandResponse, *model.AppError)

Handle function calls the respective handlers of the commands. It checks whether any HandlerFunc is present for the given command by checking in the "azureDevopsCommandHandler". If the command is present, it calls its handler function, else calls the default handler.

type HandlerFunc

type HandlerFunc func(p *Plugin, c *plugin.Context, commandArgs *model.CommandArgs, args ...string) (*model.CommandResponse, *model.AppError)

type OAuthConfig

type OAuthConfig struct {
	// contains filtered or unexported fields
}

type Plugin

type Plugin struct {
	plugin.MattermostPlugin

	Client Client

	Store store.KVStore
	// contains filtered or unexported fields
}

Plugin implements the interface expected by the Mattermost server to communicate between the server and plugin processes.

func (*Plugin) AddAuthorization

func (p *Plugin) AddAuthorization(r *http.Request, mattermostUserID string) error

AddAuthorization function to add authorization to a request.

func (*Plugin) CloseBrowserWindowWithHTTPResponse added in v1.0.0

func (p *Plugin) CloseBrowserWindowWithHTTPResponse(w http.ResponseWriter)

CloseBrowserWindowWithHTTPResponse closes the browser window

func (*Plugin) DM

func (p *Plugin) DM(mattermostUserID, format string, isSlackAttachment bool, args ...interface{}) (string, error)

DM posts a simple Direct Message to the specified user

func (*Plugin) Decode added in v1.0.0

func (p *Plugin) Decode(encoded string) ([]byte, error)

Decode decodes a base64 string into bytes

func (*Plugin) Decrypt added in v1.0.0

func (p *Plugin) Decrypt(encrypted, secret []byte) ([]byte, error)

Decrypt used for generating decrypted bytes

func (*Plugin) Encode added in v1.0.0

func (p *Plugin) Encode(encrypted []byte) string

Encode encodes bytes into base64 string

func (*Plugin) Encrypt added in v1.0.0

func (p *Plugin) Encrypt(plain, secret []byte) ([]byte, error)

Encrypt used for generating encrypted bytes

func (*Plugin) ExecuteCommand

func (p *Plugin) ExecuteCommand(c *plugin.Context, commandArgs *model.CommandArgs) (*model.CommandResponse, *model.AppError)

Handles executing a slash command

func (*Plugin) GenerateAndStoreOAuthToken added in v0.2.1

func (p *Plugin) GenerateAndStoreOAuthToken(mattermostUserID string, oauthTokenFormValues url.Values) error

GenerateAndStoreOAuthToken generates and stores OAuth token

func (*Plugin) GenerateOAuthConnectURL

func (p *Plugin) GenerateOAuthConnectURL(mattermostUserID string) string

GenerateOAuthConnectURL generates URL for Azure OAuth authorization

func (*Plugin) GenerateOAuthToken

func (p *Plugin) GenerateOAuthToken(code, state string) error

GenerateOAuthToken generates OAuth token after successful authorization

func (*Plugin) GetOffsetAndLimitFromQueryParams added in v1.1.0

func (p *Plugin) GetOffsetAndLimitFromQueryParams(r *http.Request) (offset, limit int)

func (*Plugin) GetPluginURL

func (p *Plugin) GetPluginURL() string

func (*Plugin) GetPluginURLPath

func (p *Plugin) GetPluginURLPath() string

func (*Plugin) GetSiteURL

func (p *Plugin) GetSiteURL() string

func (*Plugin) GetSubscriptionsForAccessibleChannelsOrProjects added in v1.3.0

func (p *Plugin) GetSubscriptionsForAccessibleChannelsOrProjects(subscriptionList []*serializers.SubscriptionDetails, teamID, mattermostUserID string) ([]*serializers.SubscriptionDetails, error)

func (*Plugin) HandleStaticFiles

func (p *Plugin) HandleStaticFiles()

Handles the static files under the assets directory.

func (*Plugin) InitAPI

func (p *Plugin) InitAPI() *mux.Router

Initializes the plugin REST API

func (*Plugin) InitRoutes

func (p *Plugin) InitRoutes()

Add custom routes and corresponding handlers here

func (*Plugin) IsAccessTokenExpired added in v1.0.0

func (p *Plugin) IsAccessTokenExpired(mattermostUserID string) (bool, string)

IsAccessTokenExpired checks if a user's access token is expired

func (*Plugin) IsAnyProjectLinked

func (p *Plugin) IsAnyProjectLinked(mattermostUserID string) (bool, error)

func (*Plugin) IsProjectLinked

func (p *Plugin) IsProjectLinked(projectList []serializers.ProjectDetails, project serializers.ProjectDetails) (*serializers.ProjectDetails, bool)

func (*Plugin) IsSubscriptionPresent added in v0.2.0

func (p *Plugin) IsSubscriptionPresent(subscriptionList []*serializers.SubscriptionDetails, subscription *serializers.SubscriptionDetails) (*serializers.SubscriptionDetails, bool)

func (*Plugin) MessageWillBePosted

func (p *Plugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string)

func (*Plugin) OAuthComplete

func (p *Plugin) OAuthComplete(w http.ResponseWriter, r *http.Request)

OAuthComplete captures the redirection request made by the OAuth authorization

func (*Plugin) OAuthConfig

func (p *Plugin) OAuthConfig() *OAuthConfig

OAuthConfig initialize OAuth configs

func (*Plugin) OAuthConnect

func (p *Plugin) OAuthConnect(w http.ResponseWriter, r *http.Request)

OAuthConnect redirects to the OAuth authorization URL

func (*Plugin) OnActivate

func (p *Plugin) OnActivate() error

Invoked when the plugin is activated

func (*Plugin) OnConfigurationChange

func (p *Plugin) OnConfigurationChange() error

Invoked when configuration changes may have been made.

func (*Plugin) ParseAuthToken

func (p *Plugin) ParseAuthToken(encoded string) (string, error)

func (*Plugin) ParseSubscriptionsToCommandResponse added in v1.0.0

func (p *Plugin) ParseSubscriptionsToCommandResponse(subscriptionsList []*serializers.SubscriptionDetails, channelID, createdBy, userID, command string) string

func (*Plugin) PostTaskPreview added in v1.0.0

func (p *Plugin) PostTaskPreview(linkData []string, userID, channelID string) (*model.Post, string)

postTaskPreview function returns the new post containing the preview of the work item. (UI may change in the future)

func (*Plugin) RefreshOAuthToken

func (p *Plugin) RefreshOAuthToken(mattermostUserID, refreshToken string) error

RefreshOAuthToken refreshes OAuth token

func (*Plugin) ServeHTTP

func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request)

ServeHTTP demonstrates a plugin that handles HTTP requests.

func (*Plugin) UserAlreadyConnected

func (p *Plugin) UserAlreadyConnected(mattermostUserID string) bool

UserAlreadyConnected checks if a user is already connected

func (*Plugin) WithRecovery

func (p *Plugin) WithRecovery(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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