plugin

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UserKeyPrefix   = "user_"
	OAuth2KeyPrefix = "oauth2_"
)
View Source
const (
	OAuth2KeyExpiration = 15 * time.Minute
)

Variables

View Source
var ErrNotFound = kvstore.ErrNotFound
View Source
var ErrorContentTypeNotJSON = fmt.Errorf("content type of the response is not JSON")

Functions

func ConvertSubscriptionToMap

func ConvertSubscriptionToMap(subscription *serializer.SubscriptionResponse) (map[string]interface{}, error)

func GetPageAndPerPage

func GetPageAndPerPage(r *http.Request) (page, perPage int)

func ParseSubscriptionsToCommandResponse

func ParseSubscriptionsToCommandResponse(subscriptions []*serializer.SubscriptionResponse) string

func ProcessComments added in v1.2.0

func ProcessComments(comments string, page, perPage int) []string

Types

type AuthToken

type AuthToken struct {
	Token *oauth2.Token `json:"token,omitempty"`
}

type Client

type Client interface {
	ActivateSubscriptions() (int, error)
	CreateSubscription(*serializer.SubscriptionPayload) (int, error)
	GetSubscription(subscriptionID string) (*serializer.SubscriptionResponse, int, error)
	GetAllSubscriptions(channelID, userID, subscriptionType, limit, offset string) ([]*serializer.SubscriptionResponse, int, error)
	DeleteSubscription(subscriptionID string) (int, error)
	EditSubscription(subscriptionID string, subscription *serializer.SubscriptionPayload) (int, error)
	CheckForDuplicateSubscription(*serializer.SubscriptionPayload) (bool, int, error)
	SearchRecordsInServiceNow(tableName, searchTerm, limit, offset string) ([]*serializer.ServiceNowPartialRecord, int, error)
	GetRecordFromServiceNow(tableName, sysID string) (*serializer.ServiceNowRecord, int, error)
	GetAllComments(recordType, recordID string) (string, int, error)
	AddComment(recordType, recordID string, payload *serializer.ServiceNowCommentPayload) (int, error)
}

type CommandHandleFunc

type CommandHandleFunc func(c *plugin.Context, args *model.CommandArgs, parameters []string, client Client) string

type Error

type Error struct {
	Detail  string `json:"detail"`
	Message string `json:"message"`
}

type ErrorResponse

type ErrorResponse struct {
	Error  Error  `json:"error"`
	Status string `json:"status"`
}

type OAuth2StateStore

type OAuth2StateStore interface {
	VerifyOAuth2State(state string) error
	StoreOAuth2State(state string) error
}

OAuth2StateStore manages OAuth2 state

type Plugin

type Plugin struct {
	plugin.MattermostPlugin

	CommandHandlers map[string]CommandHandleFunc
	// contains filtered or unexported fields
}

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

func NewPlugin

func NewPlugin() *Plugin

NewPlugin returns an instance of a Plugin.

func (*Plugin) CompleteOAuth2

func (p *Plugin) CompleteOAuth2(authedUserID, code, state string) error

func (*Plugin) DM

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

DM posts a simple Direct Message to the specified user

func (*Plugin) DisconnectUser

func (p *Plugin) DisconnectUser(mattermostUserID string) error

func (*Plugin) Ephemeral

func (p *Plugin) Ephemeral(userID, channelID, rootID, format string, args ...interface{})

Ephemeral sends an ephemeral message to a user

func (*Plugin) ExecuteCommand

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

func (*Plugin) GetClientFromRequest

func (p *Plugin) GetClientFromRequest(r *http.Request) Client

func (*Plugin) GetClientFromUser

func (p *Plugin) GetClientFromUser(args *model.CommandArgs, user *serializer.User) Client

func (*Plugin) GetPluginURL

func (p *Plugin) GetPluginURL() string

func (*Plugin) GetPluginURLPath

func (p *Plugin) GetPluginURLPath() string

func (*Plugin) GetRecordFromServiceNowForSubscription

func (p *Plugin) GetRecordFromServiceNowForSubscription(subscription *serializer.SubscriptionResponse, client Client, wg *sync.WaitGroup)

func (*Plugin) GetSiteURL

func (p *Plugin) GetSiteURL() string

func (*Plugin) GetUser

func (p *Plugin) GetUser(mattermostUserID string) (*serializer.User, error)

func (*Plugin) InitAPI

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

InitAPI initializes the REST API

func (*Plugin) InitOAuth2

func (p *Plugin) InitOAuth2(mattermostUserID string) (string, error)

func (*Plugin) NewClient

func (p *Plugin) NewClient(ctx context.Context, token *oauth2.Token) Client

func (*Plugin) NewEncodedAuthToken

func (p *Plugin) NewEncodedAuthToken(token *oauth2.Token) (returnToken string, returnErr error)

func (*Plugin) NewOAuth2Config

func (p *Plugin) NewOAuth2Config() *oauth2.Config

func (*Plugin) NewStore

func (p *Plugin) NewStore(api plugin.API) Store

func (*Plugin) OnActivate

func (p *Plugin) OnActivate() error

func (*Plugin) OnConfigurationChange

func (p *Plugin) OnConfigurationChange() error

OnConfigurationChange is invoked when configuration changes may have been made.

func (*Plugin) ParseAuthToken

func (p *Plugin) ParseAuthToken(encoded string) (*oauth2.Token, error)

func (*Plugin) ServeHTTP

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

ServeHTTP demonstrates a plugin that handles HTTP requests

type Store

type Store interface {
	UserStore
	OAuth2StateStore
}

type UserStore

type UserStore interface {
	LoadUser(mattermostUserID string) (*serializer.User, error)
	StoreUser(user *serializer.User) error
	DeleteUser(mattermostUserID string) error
}

Jump to

Keyboard shortcuts

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