Documentation ¶
Index ¶
- Constants
- Variables
- func ReturnStatusOK(w io.Writer)
- type AuthToken
- type Client
- type Error
- type ErrorResponse
- type FileStruct
- type GroupedPartsOutputControl
- type GroupedPartsOutputControlValue
- type MessageAttachment
- type MessageBody
- type MessageResponseBody
- type OAuth2StateStore
- type Option
- type OutputCard
- type OutputCardData
- type OutputLink
- type OutputLinkValue
- type OutputText
- type Picker
- type Plugin
- func (p *Plugin) CompleteOAuth2(authedUserID, code, state string) error
- func (p *Plugin) CreateDisconnectUserAttachment() *model.SlackAttachment
- func (p *Plugin) CreateGroupedPartsOutputControlAttachment(body GroupedPartsOutputControlValue) *model.SlackAttachment
- func (p *Plugin) CreateOutputCardAttachment(body *OutputCardData) *model.SlackAttachment
- func (p *Plugin) CreateOutputLinkAttachment(body *OutputLink) *model.SlackAttachment
- func (p *Plugin) CreatePickerAttachment(body *Picker) *model.SlackAttachment
- func (p *Plugin) CreateTopicPickerControlAttachment(body *TopicPickerControl) *model.SlackAttachment
- func (p *Plugin) DM(mattermostUserID, format string, args ...interface{}) (string, error)
- func (p *Plugin) DMWithAttachments(mattermostUserID string, attachments ...*model.SlackAttachment) (string, error)
- func (p *Plugin) DisconnectUser(mattermostUserID string) error
- func (p *Plugin) Ephemeral(userID, channelID, format string, args ...interface{})
- func (p *Plugin) GetDisconnectUserPost(mattermostUserID, message string) (*model.Post, error)
- func (p *Plugin) GetPluginURL() string
- func (p *Plugin) GetPluginURLPath() string
- func (p *Plugin) GetPostWithSlackAttachment(mattermostUserID string, attachments ...*model.SlackAttachment) (*model.Post, error)
- func (p *Plugin) GetSiteURL() string
- func (p *Plugin) GetUser(mattermostUserID string) (*serializer.User, error)
- func (p *Plugin) InitOAuth2(mattermostUserID string) (string, error)
- func (p *Plugin) MakeClient(ctx context.Context, token *oauth2.Token) Client
- func (p *Plugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post)
- func (p *Plugin) NewEncodedAuthToken(token *oauth2.Token) (returnToken string, returnErr error)
- func (p *Plugin) NewOAuth2Config() *oauth2.Config
- func (p *Plugin) NewStore(api plugin.API) Store
- func (p *Plugin) OnActivate() error
- func (p *Plugin) OnConfigurationChange() error
- func (p *Plugin) ParseAuthToken(encoded string) (*oauth2.Token, error)
- func (p *Plugin) ProcessResponse(data []byte) error
- func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request)
- type ServiceNowOAuthToken
- type Store
- type TopicPickerControl
- type UserStore
- type VirtualAgentRequestBody
- type VirtualAgentResponse
Constants ¶
View Source
const ( HeaderMattermostUserID = "Mattermost-User-ID" HeaderServiceNowUserID = "ServiceNow-User-ID" // Used for storing the token in the request context to pass from one middleware to another // #nosec G101 -- This is a false positive. The below line is not a hardcoded credential ContextTokenKey ServiceNowOAuthToken = "ServiceNow-Oauth-Token" ConnectSuccessMessage = "Thanks for linking your ServiceNow account!\n" + "Your ServiceNow account (*%s*) has been connected to Mattermost." WelcomePretextMessage = "Welcome to the Mattermost ServiceNow Virtual Agent.\n" + "I'm here to help you. Let's start by linking your ServiceNow account.\n[Link to ServiceNow](%s)" GenericErrorMessage = "Something went wrong. Please try again later." PathOAuth2Connect = "/oauth2/connect" PathOAuth2Complete = "/oauth2/complete" PathUserDisconnect = "/user/disconnect" PathGetUser = "/api/now/table/sys_user" PathVirtualAgentWebhook = "/nowbot/processResponse" PathVirtualAgentBotIntegration = "/api/sn_va_as_service/bot/integration" PathActionOptions = "/action_options" SysQueryParam = "sysparm_query" BotUsername = "servicenow-virtual-agent" BotDisplayName = "ServiceNow Virtual Agent" BotDescription = "A bot account created by the plugin ServiceNow Virtual Agent." DisconnectKeyword = "disconnect" DisconnectUserContextName = "Disconnect" DisconnectUserConfirmationMessge = "Are you sure you want to disconnect your ServiceNow account?" DisconnectUserRejectedMessage = "You're still connected to your ServiceNow account." DisconnectUserSuccessMessage = "Successfully disconnected your ServiceNow account." AlreadyDisconnectedMessage = "You're already disconnected from your ServiceNow account." StartConversationAction = "START_CONVERSATION" OutputTextUIType = "OutputText" InputTextUIType = "InputText" FileUploadUIType = "FileUpload" TopicPickerControlUIType = "TopicPickerControl" PickerUIType = "Picker" BooleanUIType = "Boolean" OutputLinkUIType = "OutputLink" GroupedPartsOutputControlUIType = "GroupedPartsOutputControl" OutputCardUIType = "OutputCard" ItemTypeImage = "image" ItemTypeFile = "file" UploadImageMessage = "\n(**Note:** Please upload an image using the Mattermost `Upload files` option OR use the shorthand `Ctrl+U`.)" UploadFileMessage = "\n(**Note:** Please upload a file using the Mattermost `Upload files` option OR use the shorthand `Ctrl+U`.)" PathParamEncryptedFileInfo = "encryptedFileInfo" AttachmentLinkExpiryTimeInMinutes = 15 )
View Source
const ( EmptyServiceNowURLErrorMessage = "serviceNow URL should not be empty" EmptyServiceNowOAuthClientIDErrorMessage = "serviceNow OAuth clientID should not be empty" EmptyServiceNowOAuthClientSecretErrorMessage = "serviceNow OAuth clientSecret should not be empty" EmptyEncryptionSecretErrorMessage = "encryption secret should not be empty" EmptyWebhookSecretErrorMessage = "webhook secret should not be empty" )
#nosec G101 -- This is a false positive. The below line is not a hardcoded credential
View Source
const ( UserKeyPrefix = "user_" OAuth2KeyPrefix = "oauth2_" )
View Source
const (
OAuth2KeyExpiration = 15 * time.Minute
)
Variables ¶
View Source
var ErrNotFound = kvstore.ErrNotFound
Functions ¶
func ReturnStatusOK ¶
Types ¶
type Client ¶
type Client interface { GetMe(mattermostUserID string) (*serializer.ServiceNowUser, error) StartConverstaionWithVirtualAgent(userID string) error SendMessageToVirtualAgentAPI(userID, messageText string, typed bool, attachment *MessageAttachment) error }
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
type FileStruct ¶ added in v1.2.0
type GroupedPartsOutputControl ¶
type GroupedPartsOutputControl struct { UIType string `json:"uiType"` Group string `json:"group"` Header string `json:"header"` Type string `json:"type"` Values []GroupedPartsOutputControlValue `json:"values"` }
type MessageAttachment ¶ added in v1.2.0
type MessageBody ¶
type MessageBody struct { Attachment *MessageAttachment `json:"attachment"` Text string `json:"text"` Typed bool `json:"typed"` }
type MessageResponseBody ¶
type MessageResponseBody struct {
Value interface{}
}
func (*MessageResponseBody) UnmarshalJSON ¶
func (m *MessageResponseBody) UnmarshalJSON(data []byte) error
type OAuth2StateStore ¶
type OAuth2StateStore interface { VerifyOAuth2State(state string) error StoreOAuth2State(state string) error }
OAuth2StateStore manages OAuth2 state
type OutputCard ¶
type OutputCardData ¶
type OutputLink ¶
type OutputLinkValue ¶
type OutputLinkValue struct {
Action string `json:"action"`
}
type OutputText ¶
type Picker ¶
type Picker struct { UIType string `json:"uiType"` Group string `json:"group"` Required bool `json:"required"` NLUTextEnabled bool `json:"nluTextEnabled"` Label string `json:"label"` ItemType string `json:"itemType"` Options []Option `json:"options"` Style string `json:"style"` MultiSelect bool `json:"multiSelect"` }
type Plugin ¶
type Plugin struct { plugin.MattermostPlugin // contains filtered or unexported fields }
Plugin implements the interface expected by the Mattermost server to communicate between the server and plugin processes.
func (*Plugin) CompleteOAuth2 ¶
func (*Plugin) CreateDisconnectUserAttachment ¶
func (p *Plugin) CreateDisconnectUserAttachment() *model.SlackAttachment
func (*Plugin) CreateGroupedPartsOutputControlAttachment ¶
func (p *Plugin) CreateGroupedPartsOutputControlAttachment(body GroupedPartsOutputControlValue) *model.SlackAttachment
func (*Plugin) CreateOutputCardAttachment ¶
func (p *Plugin) CreateOutputCardAttachment(body *OutputCardData) *model.SlackAttachment
func (*Plugin) CreateOutputLinkAttachment ¶
func (p *Plugin) CreateOutputLinkAttachment(body *OutputLink) *model.SlackAttachment
func (*Plugin) CreatePickerAttachment ¶
func (p *Plugin) CreatePickerAttachment(body *Picker) *model.SlackAttachment
func (*Plugin) CreateTopicPickerControlAttachment ¶
func (p *Plugin) CreateTopicPickerControlAttachment(body *TopicPickerControl) *model.SlackAttachment
func (*Plugin) DMWithAttachments ¶
func (p *Plugin) DMWithAttachments(mattermostUserID string, attachments ...*model.SlackAttachment) (string, error)
DMWithAttachments posts a Direct Message that contains Slack attachments. Often used to include post actions.
func (*Plugin) DisconnectUser ¶
func (*Plugin) GetDisconnectUserPost ¶
func (*Plugin) GetPluginURL ¶
func (*Plugin) GetPluginURLPath ¶
func (*Plugin) GetPostWithSlackAttachment ¶
func (*Plugin) GetSiteURL ¶
func (*Plugin) GetUser ¶
func (p *Plugin) GetUser(mattermostUserID string) (*serializer.User, error)
func (*Plugin) MakeClient ¶
func (*Plugin) MessageHasBeenPosted ¶
func (*Plugin) NewEncodedAuthToken ¶
func (*Plugin) NewOAuth2Config ¶
func (*Plugin) OnActivate ¶
func (*Plugin) OnConfigurationChange ¶
OnConfigurationChange is invoked when configuration changes may have been made.
func (*Plugin) ParseAuthToken ¶
func (*Plugin) ProcessResponse ¶
type ServiceNowOAuthToken ¶
type ServiceNowOAuthToken string
type Store ¶
type Store interface { UserStore OAuth2StateStore }
type TopicPickerControl ¶
type UserStore ¶
type UserStore interface { LoadUser(mattermostUserID string) (*serializer.User, error) StoreUser(user *serializer.User) error DeleteUser(mattermostUserID string) error LoadUserWithSysID(mattermostUserID string) (*serializer.User, error) }
type VirtualAgentRequestBody ¶
type VirtualAgentRequestBody struct { Action string `json:"action"` Message *MessageBody `json:"message"` RequestID string `json:"requestId"` UserID string `json:"userId"` }
type VirtualAgentResponse ¶
type VirtualAgentResponse struct { VirtualAgentRequestBody Body []MessageResponseBody `json:"body"` }
Click to show internal directories.
Click to hide internal directories.