slack.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package integrations
  2. import "gorm.io/gorm"
  3. // SlackIntegration is a webhook notifier to a specific channel in a Slack workspace.
  4. type SlackIntegration struct {
  5. gorm.Model
  6. SharedOAuthModel
  7. // The name of the auth mechanism
  8. Client OAuthIntegrationClient `json:"client"`
  9. // The id of the user that linked this auth mechanism
  10. UserID uint `json:"user_id"`
  11. // The project that this integration belongs to
  12. ProjectID uint `json:"project_id"`
  13. // The ID for the Slack team
  14. TeamID string
  15. // The name of the Slack team
  16. TeamName string
  17. // The icon url for the Slack team
  18. TeamIconURL string
  19. // The channel name that the Slack app is installed in
  20. Channel string
  21. // The channel id that the Slack app is installed in
  22. ChannelID string
  23. // The URL for configuring the workspace app instance
  24. ConfigurationURL string
  25. // ------------------------------------------------------------------
  26. // All fields below encrypted before storage.
  27. // ------------------------------------------------------------------
  28. // The webhook to call
  29. Webhook []byte
  30. }
  31. // SlackIntegrationExternal is an external SlackIntegration to be shared over
  32. // rest
  33. type SlackIntegrationExternal struct {
  34. ID uint `json:"id"`
  35. ProjectID uint `json:"project_id"`
  36. // The ID for the Slack team
  37. TeamID string `json:"team_id"`
  38. // The name of the Slack team
  39. TeamName string `json:"team_name"`
  40. // The icon url for the Slack team
  41. TeamIconURL string `json:"team_icon_url"`
  42. // The channel name that the Slack app is installed in
  43. Channel string `json:"channel"`
  44. // The URL for configuring the workspace app instance
  45. ConfigurationURL string `json:"configuration_url"`
  46. }
  47. // Externalize generates an external SlackIntegration to be shared over
  48. // rest
  49. func (s *SlackIntegration) Externalize() *SlackIntegrationExternal {
  50. return &SlackIntegrationExternal{
  51. ID: s.ID,
  52. ProjectID: s.ProjectID,
  53. TeamID: s.TeamID,
  54. TeamName: s.TeamName,
  55. TeamIconURL: s.TeamIconURL,
  56. Channel: s.Channel,
  57. ConfigurationURL: s.ConfigurationURL,
  58. }
  59. }