slack.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. }
  34. // SlackIntegrationExternal is an external SlackIntegration to be shared over
  35. // rest
  36. type SlackIntegrationExternal struct {
  37. ID uint `json:"id"`
  38. ProjectID uint `json:"project_id"`
  39. // The ID for the Slack team
  40. TeamID string `json:"team_id"`
  41. // The name of the Slack team
  42. TeamName string `json:"team_name"`
  43. // The icon url for the Slack team
  44. TeamIconURL string `json:"team_icon_url"`
  45. // The channel name that the Slack app is installed in
  46. Channel string `json:"channel"`
  47. // The URL for configuring the workspace app instance
  48. ConfigurationURL string `json:"configuration_url"`
  49. }
  50. // Externalize generates an external SlackIntegration to be shared over
  51. // rest
  52. func (s *SlackIntegration) Externalize() *SlackIntegrationExternal {
  53. return &SlackIntegrationExternal{
  54. ID: s.ID,
  55. ProjectID: s.ProjectID,
  56. TeamID: s.TeamID,
  57. TeamName: s.TeamName,
  58. TeamIconURL: s.TeamIconURL,
  59. Channel: s.Channel,
  60. ConfigurationURL: s.ConfigurationURL,
  61. }
  62. }