Documentation ¶
Index ¶
- Constants
- Variables
- func EventAttendeesString(e *calendar.Event) string
- func EventDateTimeString(e *calendar.Event) string
- func EventDiffString(before *Event, after *calendar.Event, calSummary string) string
- func EventSummaryString(e *calendar.Event) string
- func HandleCall(p string, h HandlerFunc)
- func HandleCommand(command Command)
- func Init()
- func RespondWithJSON(creq CallRequest, message string, v interface{}) apps.CallResponse
- type CallRequest
- func (creq CallRequest) DeleteEvent(googleEmail, calID, eventID string) error
- func (creq CallRequest) DeleteSub(s *Sub) error
- func (creq CallRequest) ListSubs(creatorID string) ([]Sub, error)
- func (creq CallRequest) LoadEvent(googleEmail, calID, eventID string) (*Event, error)
- func (creq CallRequest) LoadSub(subID string) (*Sub, error)
- func (creq CallRequest) StoreEvent(googleEmail, calID string, e *Event) error
- func (creq CallRequest) StoreSub(s *Sub, updateIndex bool) error
- type Command
- type Event
- type HandlerFunc
- type ServiceAccount
- type Sub
- type User
Constants ¶
View Source
const ( // Individual subscriptions are stored in the "s" namespace, as "[s]{id}", // where id is the generated ID of the subscription, also known as channel // ID in Google terms. KVSubPrefix = "s" // Indices of subscriptions are stored in the "si" namespace, as // "[si]{userID}". The global (channel) subscriptions are stored under the // "bot_subs". KVSubIndexPrefix = "si" // Individual events are stored in the "e" namespace, as // "[e]base64({googleEmail}/{calID}/{eventID})". KVEventPrefix = "e" // The name of the key that stores the list of global subscriptions. KVBotSubscriptionsKey = "bot_subs" )
KV store: subscriptions
View Source
const IconPath = "icon.png"
Variables ¶
View Source
var AppPathPrefix = ""
View Source
var BuildDate string
View Source
var BuildHash string
View Source
var BuildHashShort string
View Source
var Log = utils.MustMakeCommandLogger(zapcore.DebugLevel)
View Source
var OAuth2Scopes = []string{
calendar.CalendarScope,
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
}
Functions ¶
func EventAttendeesString ¶
func EventAttendeesString(e *calendar.Event) string
func EventDateTimeString ¶
func EventDateTimeString(e *calendar.Event) string
func EventDiffString ¶
func EventSummaryString ¶
func EventSummaryString(e *calendar.Event) string
func HandleCall ¶
func HandleCall(p string, h HandlerFunc)
func HandleCommand ¶
func HandleCommand(command Command)
func RespondWithJSON ¶
func RespondWithJSON(creq CallRequest, message string, v interface{}) apps.CallResponse
Types ¶
type CallRequest ¶
type CallRequest struct { apps.CallRequest // contains filtered or unexported fields }
func (CallRequest) DeleteEvent ¶
func (creq CallRequest) DeleteEvent(googleEmail, calID, eventID string) error
func (CallRequest) DeleteSub ¶
func (creq CallRequest) DeleteSub(s *Sub) error
func (CallRequest) LoadEvent ¶
func (creq CallRequest) LoadEvent(googleEmail, calID, eventID string) (*Event, error)
func (CallRequest) StoreEvent ¶
func (creq CallRequest) StoreEvent(googleEmail, calID string, e *Event) error
type Command ¶
type Command struct { Name string Hint string Description string BaseSubmit *apps.Call BaseForm *apps.Form Handler func(CallRequest) apps.CallResponse }
type HandlerFunc ¶
type HandlerFunc func(CallRequest) apps.CallResponse
func FormHandler ¶
func FormHandler(h func(CallRequest) (apps.Form, error)) HandlerFunc
func LookupHandler ¶
func LookupHandler(h func(CallRequest) []apps.SelectOption) HandlerFunc
func RequireAdmin ¶
func RequireAdmin(h HandlerFunc) HandlerFunc
func RequireGoogleAuth ¶
func RequireGoogleAuth(h HandlerFunc) HandlerFunc
func RequireGoogleUser ¶
func RequireGoogleUser(h HandlerFunc) HandlerFunc
type ServiceAccount ¶
type ServiceAccount struct { // Mode is either "api_key", "account_json", or "" implying no service // account is to be used, and the corresponding functionality disabled. Mode string `json:"mode,omitempty"` // fMode APIKey string `json:"api_key,omitempty"` // fAPIKey AccountJSON string `json:"account_json,omitempty"` // fAccountJSON }
func NewServiceAccount ¶
func NewServiceAccount(mode, apiKey, serviceAccout string) ServiceAccount
func ServiceAccountFromRequest ¶
func ServiceAccountFromRequest(creq CallRequest) ServiceAccount
func (ServiceAccount) AuthOption ¶
func (sa ServiceAccount) AuthOption(ctx context.Context, userEmail string) (option.ClientOption, error)
func (ServiceAccount) String ¶
func (sa ServiceAccount) String() string
type Sub ¶
type Sub struct { // SubID is a unique ID generated at the creation of the Sub. It is also // used as the channel ID on the Google side. SubID string `json:"id"` // CreatorID is the Mattermost ID of the user who created the subscription. // It is used to namespace the cached events for the user as they are stored // by the webhook handler. CreatorID string `json:"creator_id,omitempty"` // GoogleEmail is the email ID of the Google user, used for impersonation // with a service account. GoogleEmail string `json:"google_user_id"` // CalendarID of the calendar subscribed to. CalendarID string `json:"calendar_id,omitempty"` // CalendarSummary is the summary (title) of the calendar, also used as the // Sub name. Updated on change every time Events.List is invoked, so should // be in sync with the actual name of the calendar. CalendarSummary string `json:"calendar_summary,omitempty"` // Google channel for the webhook. Google *calendar.Channel `json:"google,omitempty"` // SyncToken to use for the the next update. SyncToken string `json:"next_sync_token,omitempty"` // MattermostUserID to DM on updates. // TODO: support subscribing to channels MattermostUserID string `json:"mattermost_user_id"` }
Source Files ¶
- app.go
- auth.go
- bindings.go
- call_request.go
- cmd_configure.go
- cmd_connect.go
- cmd_debug_get_event.go
- cmd_debug_list_calendars.go
- cmd_debug_list_events.go
- cmd_debug_stop_watch.go
- cmd_debug_user_info.go
- cmd_info.go
- cmd_watch_list.go
- cmd_watch_start.go
- cmd_watch_stop.go
- command.go
- event.go
- field_calendar_id.go
- field_event_id.go
- field_subscription_id.go
- fields_debug.go
- modal_configure.go
- sub.go
- todo_raw_notes.go
- user.go
- webhook.go
Click to show internal directories.
Click to hide internal directories.