Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Brightscout/mattermost-plugin-azu…
Browse files Browse the repository at this point in the history
…re-devops into MI-2010_1
  • Loading branch information
avas27JTG committed Sep 5, 2022
2 parents bb12691 + c7a920b commit bd89151
Show file tree
Hide file tree
Showing 67 changed files with 2,186 additions and 731 deletions.
21 changes: 15 additions & 6 deletions server/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ package constants
const (
// Bot configs
BotUsername = "azuredevops"
BotDisplayName = "Azure Devops"
BotDescription = "A bot account created by the Azure Devops plugin."
BotDisplayName = "Azure DevOps"
BotDescription = "A bot account created by the Azure DevOps plugin."

// Plugin configs
PluginID = "mattermost-plugin-azure-devops"
ChannelID = "channel_id"
HeaderMattermostUserID = "Mattermost-User-ID"
// TODO: Change later according to the needs.
HeaderMattermostUserIDAPI = "User-ID"

// Command configs
CommandTriggerName = "azuredevops"
HelpText = "###### Mattermost Azure Devops Plugin - Slash Command Help\n"
InvalidCommand = "Invalid command parameters. Please use `/azuredevops help` for more information."
HelpText = "###### Mattermost Azure DevOps Plugin - Slash Command Help\n" +
"* `/azuredevops connect` - Connect your Mattermost account to your Azure DevOps account.\n" +
"* `/azuredevops disconnect` - Disconnect your Mattermost account from your Azure DevOps account.\n" +
"* `/azuredevops link [projectURL]` - Link your project to a current channel.\n" +
"* `/azuredevops boards create [title] [description]` - Create a new task for your project.\n" +
"* `/azuredevops subscribe` - Create subscriptions to track changes in tasks for your linked projects.\n"
InvalidCommand = "Invalid command parameters. Please use `/azuredevops help` for more information."

// Get task link preview constants
HTTPS = "https:"
Expand All @@ -38,6 +41,12 @@ const (
Update = "update"
Delete = "delete"

// Path params
PathParamTeamID = "team_id"

// URL query params constants
ProjectParam = "project"

// Authorization constants
Bearer = "Bearer"
Authorization = "Authorization"
Expand Down
22 changes: 13 additions & 9 deletions server/constants/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ const (
// TODO: all these messages are to be verified from Mike at the end
// Generic
GenericErrorMessage = "Something went wrong, please try again later"
ConnectAccount = "[Click here to link your Azure DevOps account](%s%s)"
ConnectAccountFirst = "You do not have any Azure Devops account connected. Kindly link the account first"
UserConnected = "Your Azure Devops account is succesfully connected!"
UserAlreadyConnected = "Your Azure Devops account is already connected"
UserDisconnected = "Your Azure Devops account is now disconnected"
ConnectAccount = "[Click here to connect your Azure DevOps account](%s%s)"
ConnectAccountFirst = "Your Azure DevOps account is not connected \n%s"
UserConnected = "Your Azure DevOps account is successfully connected!"
UserAlreadyConnected = "Your Azure DevOps account is already connected"
UserDisconnected = "Your Azure DevOps account is now disconnected"
CreatedTask = "Link for newly created task: %s"
TaskTitle = "[%s #%d: %s](%s)"
TaskPreviewMessage = "State: %s\nAssigned To: %s\nDescription: %s"
AlreadyLinkedProject = "This project is already linked."
NoProjectLinked = "No project is linked, please link a project."

// Validations
// Validations Errors
OrganizationRequired = "organization is required"
ProjectRequired = "project is required"
TaskTypeRequired = "task type is required"
TaskTitleRequired = "task title is required"
EventTypeRequired = "event type is required"
ChannelNameRequired = "channel name is required"
ChannelIDRequired = "channel ID is required"
)

const (
Expand All @@ -36,11 +37,14 @@ const (
GetProjectListError = "Error getting Project List"
ErrorFetchProjectList = "Error in fetching project list"
ErrorDecodingBody = "Error in decoding body"
ProjectNotFound = "Requested project does not exists"
ErrorUnlinkProject = "Error in unlinking the project"
FetchSubscriptionListError = "Error in fetching subscription list"
CreateSubscriptionError = "Error in creating subscription"
ProjectNotLinked = "Requested project is not linked"
GetSubscriptionListError = "Error getting Subscription List"
SubscriptionAlreadyPresent = "Subscription is already present"
SubscriptionAlreadyPresent = "Requested subscription already exists"
SubscriptionNotFound = "Requested subscription does not exists"
ErrorLoadingUserData = "Error in loading user data"
ErrorLoadingDataFromKVStore = "Error in loading data from KV store"
ProjectNotFound = "Requested project does not exist"
ErrorUnlinkProject = "Error in unlinking the project"
)
1 change: 1 addition & 0 deletions server/constants/oauth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
Scopes = "vso.code vso.work_full"
ClientAssertionType = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer"
GrantTypeRefresh = "refresh_token"

// URL
BaseOauthURL = "https://app.vssps.visualstudio.com"
Expand Down
26 changes: 14 additions & 12 deletions server/constants/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ package constants

const (
// Plugin API Routes
APIPrefix = "/api/v1"
WildRoute = "{anything:.*}"
PathOAuthConnect = "/oauth/connect"
PathOAuthCallback = "/oauth/complete"
PathLinkedProjects = "/project/link"
PathGetAllLinkedProjects = "/project/link"
PathUnlinkProject = "/project/unlink"
PathUser = "/user"
PathCreateTasks = "/tasks"
PathLinkProject = "/link"
PathSubscriptions = "/subscriptions"
PathSubscriptionotifications = "/notification"
APIPrefix = "/api/v1"
WildRoute = "{anything:.*}"
PathOAuthConnect = "/oauth/connect"
PathOAuthCallback = "/oauth/complete"
PathLinkedProjects = "/project/link"
PathGetAllLinkedProjects = "/project/link"
PathUnlinkProject = "/project/unlink"
PathUser = "/user"
PathCreateTasks = "/tasks"
PathLinkProject = "/link"
PathSubscriptions = "/subscriptions"
PathSubscriptionNotifications = "/notification"
PathGetUserChannelsForTeam = "/channels/{team_id:[A-Za-z0-9]+}"

// Azure API paths
CreateTask = "/%s/%s/_apis/wit/workitems/$%s?api-version=7.1-preview.3"
GetTask = "%s/_apis/wit/workitems/%s?api-version=7.1-preview.3"
GetProject = "/%s/_apis/projects/%s?api-version=7.1-preview.4"
CreateSubscription = "/%s/_apis/hooks/subscriptions?api-version=6.0"
DeleteSubscription = "/%s/_apis/hooks/subscriptions/%s?api-version=6.0"
)
7 changes: 4 additions & 3 deletions server/constants/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package constants
import "time"

const (
AtomicRetryLimit = 5
AtomicRetryWait = 30 * time.Millisecond
TTLSecondsForOAuthState int64 = 60
AtomicRetryLimit = 5
AtomicRetryWait = 30 * time.Millisecond
TTLSecondsForOAuthState int64 = 60
TokenExpiryTimeBufferInMinutes = 5

// KV store prefix keys
OAuthPrefix = "oAuth_%s"
Expand Down
Loading

0 comments on commit bd89151

Please sign in to comment.