slack.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package integrations
  2. import (
  3. "gorm.io/gorm"
  4. "github.com/porter-dev/porter/api/types"
  5. )
  6. // SlackIntegration is a webhook notifier to a specific channel in a Slack workspace.
  7. type SlackIntegration struct {
  8. gorm.Model
  9. SharedOAuthModel
  10. // The name of the auth mechanism
  11. Client types.OAuthIntegrationClient `json:"client"`
  12. // The id of the user that linked this auth mechanism
  13. UserID uint `json:"user_id"`
  14. // The project that this integration belongs to
  15. ProjectID uint `json:"project_id"`
  16. // The ID for the Slack team
  17. TeamID string
  18. // The name of the Slack team
  19. TeamName string
  20. // The icon url for the Slack team
  21. TeamIconURL string
  22. // The channel name that the Slack app is installed in
  23. Channel string
  24. // The channel id that the Slack app is installed in
  25. ChannelID string
  26. // The URL for configuring the workspace app instance
  27. ConfigurationURL string
  28. // ------------------------------------------------------------------
  29. // All fields below encrypted before storage.
  30. // ------------------------------------------------------------------
  31. // The webhook to call
  32. Webhook []byte
  33. // NotificationConfigID is the ID of the notification config to use
  34. NotificationConfigID uint `gorm:"default:0"`
  35. }
  36. func (s *SlackIntegration) ToSlackIntegraionType() *types.SlackIntegration {
  37. return &types.SlackIntegration{
  38. ID: s.ID,
  39. ProjectID: s.ProjectID,
  40. TeamID: s.TeamID,
  41. TeamName: s.TeamName,
  42. TeamIconURL: s.TeamIconURL,
  43. Channel: s.Channel,
  44. ConfigurationURL: s.ConfigurationURL,
  45. NotificationConfigID: s.NotificationConfigID,
  46. }
  47. }