function

package module
v0.0.0-...-df75068 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 14 Imported by: 0

README

shortcut-to-teams

📝 A simple Google Cloud Function in Go to transform / proxy Shortcut (formerly, Clubhouse Project Management) webhooks to Microsoft Teams.

This project is still under development, and it does not handle many cases. It has been tested with the Go 1.13 runtime.

Notification in Teams

Forked from https://github.com/Courtsite/clubhouse-to-discord

Getting Started

Prerequisites
  • Ensure you have gcloud installed:
  • Ensure you have authenticated with Google Cloud: gcloud init
  • (Optional) Set your current working project: gcloud config set project <project>
Deployment
  1. Clone / download a copy of this repository
  2. Copy .env.sample.yaml to .env.yaml, and modify the environment variables declared in the file
  3. Run ./deploy.sh
  4. Configure Shortcut webhooks integration in https://app.shortcut.com/<workspace>/settings/integrations/outgoing-webhook

Shortcut's Generic Outgoing Webhook Integration

Shortcut Generate API Token

Migrating from Clubhouse to Shortcut

As of 2021-10-05, we have updated the function to reference "Shortcut" instead of the former "Clubhouse".

This updated function uses the latest Shortcut REST API specs. We suggest deploying this updated version, and updating your webhooks, before deleting the old clubhouse-to-teams.

If you do not update, your function may not work after November 13th, 2021.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F

Types

type Fact

type Fact struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type GetMemberResponse

type GetMemberResponse struct {
	CreatedAt  time.Time `json:"created_at"`
	Disabled   bool      `json:"disabled"`
	EntityType string    `json:"entity_type"`
	GroupIds   []string  `json:"group_ids"`
	ID         string    `json:"id"`
	Profile    struct {
		Deactivated bool `json:"deactivated"`
		DisplayIcon struct {
			CreatedAt  time.Time `json:"created_at"`
			EntityType string    `json:"entity_type"`
			ID         string    `json:"id"`
			UpdatedAt  time.Time `json:"updated_at"`
			URL        string    `json:"url"`
		} `json:"display_icon"`
		EmailAddress           string `json:"email_address"`
		EntityType             string `json:"entity_type"`
		GravatarHash           string `json:"gravatar_hash"`
		ID                     string `json:"id"`
		MentionName            string `json:"mention_name"`
		Name                   string `json:"name"`
		TwoFactorAuthActivated bool   `json:"two_factor_auth_activated"`
	} `json:"profile"`
	Role      string    `json:"role"`
	UpdatedAt time.Time `json:"updated_at"`
}

https://shortcut.com/api/rest/v3#Get-Member

type MessageCard

type MessageCard struct {
	Type             string            `json:"@type"`
	Context          string            `json:"@context"`
	Summary          string            `json:"summary,omitempty"`
	Title            string            `json:"title,omitempty"`
	Text             string            `json:"text,omitempty"`
	ThemeColor       string            `json:"themeColor,omitempty"`
	Sections         []Section         `json:"sections,omitempty"`
	PotentialActions []PotentialAction `json:"potentialAction,omitempty"`
}

type PotentialAction

type PotentialAction struct {
	Type    string              `json:"@type"`
	Name    string              `json:"name"`
	Targets []map[string]string `json:"targets,omitempty"`
}

type Section

type Section struct {
	ActivityTitle    string `json:"activityTitle,omitempty"`
	ActivitySubtitle string `json:"activitySubtitle,omitempty"`
	Facts            []Fact `json:"facts,omitempty"`
}

type ShortcutAction

type ShortcutAction struct {
	Action          string          `json:"action"`
	AppURL          string          `json:"app_url"`
	AuthorID        string          `json:"author_id"`
	Changes         ShortcutChanges `json:"changes"`
	Complete        bool            `json:"complete,omitempty"`
	Description     string          `json:"description"`
	EntityType      string          `json:"entity_type"`
	EpicID          int             `json:"epic_id"`
	Estimate        int             `json:"estimate,omitempty"`
	FollowerIds     []string        `json:"follower_ids"`
	ID              int             `json:"id"`
	IterationID     int             `json:"iteration_id"`
	MilestoneID     int             `json:"milestone_id"`
	Name            string          `json:"name"`
	OwnerIds        []string        `json:"owner_ids"`
	Position        int64           `json:"position"`
	ProjectID       int             `json:"project_id"`
	RequestedByID   string          `json:"requested_by_id"`
	StoryType       string          `json:"story_type"`
	TaskIds         []int           `json:"task_ids,omitempty"`
	Town            *string         `json:"town,omitempty"`
	Text            string          `json:"text"`
	URL             string          `json:"url"`
	WorkflowStateID int             `json:"workflow_state_id"`
}

type ShortcutApiClient

type ShortcutApiClient struct {
	ApiToken string
}

func (*ShortcutApiClient) GetMember

func (c *ShortcutApiClient) GetMember(memberPublicID string) (*GetMemberResponse, error)

type ShortcutChanges

type ShortcutChanges struct {
	Archived *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"archived,omitempty"`
	Blocker *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"blocker,omitempty"`
	CommentIds *struct {
		Adds    []int `json:"adds"`
		Removes []int `json:"removes"`
	} `json:"comment_ids,omitempty"`
	Completed *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"completed,omitempty"`
	CompletedAt *struct {
		New time.Time `json:"new"`
	} `json:"completed_at,omitempty"`
	Deadline *struct {
		New *time.Time `json:"new,omitempty"`
		Old *time.Time `json:"old,omitempty"`
	} `json:"deadline,omitempty"`
	EpicID *struct {
		New *int `json:"new,omitempty"`
		Old *int `json:"old,omitempty"`
	} `json:"epic_id,omitempty"`
	Estimate *struct {
		New *int `json:"new,omitempty"`
		Old *int `json:"old,omitempty"`
	} `json:"estimate,omitempty"`
	ExternalLinks *struct {
		Adds    []string `json:"adds"`
		Removes []string `json:"removes"`
	} `json:"external_links,omitempty"`
	FollowerIds *struct {
		Adds []string `json:"adds"`
	} `json:"follower_ids,omitempty"`
	IterationID *struct {
		New *int `json:"new,omitempty"`
		Old *int `json:"old,omitempty"`
	} `json:"iteration_id,omitempty"`
	LabelIds *struct {
		Adds    []int `json:"adds"`
		Removes []int `json:"removes"`
	} `json:"label_ids,omitempty"`
	Name *struct {
		New string `json:"new"`
		Old string `json:"old"`
	} `json:"name,omitempty"`
	OwnerIds *struct {
		Adds    []string `json:"adds"`
		Removes []string `json:"removes"`
	} `json:"owner_ids,omitempty"`
	Position *struct {
		New int64 `json:"new"`
		Old int64 `json:"old"`
	} `json:"position,omitempty"`
	ProjectID *struct {
		New int `json:"new"`
		Old int `json:"old"`
	} `json:"project_id,omitempty"`
	Started *struct {
		New bool `json:"new"`
		Old bool `json:"old"`
	} `json:"started,omitempty"`
	StartedAt *struct {
		New time.Time `json:"new"`
	} `json:"started_at,omitempty"`
	StoryType *struct {
		New string `json:"new"`
		Old string `json:"old"`
	} `json:"story_type,omitempty"`
	Text *struct {
		New string `json:"new"`
		Old string `json:"old"`
	} `json:"text,omitempty"`
	WorkflowStateID *struct {
		New int `json:"new"`
		Old int `json:"old"`
	} `json:"workflow_state_id,omitempty"`
}

type ShortcutReference

type ShortcutReference struct {
	AppURL     string `json:"app_url"`
	EntityType string `json:"entity_type"`
	ID         int    `json:"id"`
	Name       string `json:"name"`
	Type       string `json:"type"`
}

type ShortcutWebhook

type ShortcutWebhook struct {
	Actions    []ShortcutAction    `json:"actions"`
	ChangedAt  time.Time           `json:"changed_at"`
	ID         string              `json:"id"`
	MemberID   string              `json:"member_id"`
	PrimaryID  int                 `json:"primary_id"`
	References []ShortcutReference `json:"references"`
	Paper      *string             `json:"paper,omitempty"`
	Version    string              `json:"version"`
}

Expanded from https://shortcut.com/api/webhook/v1#Webhook-Format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL