Fixed lint errors (#243)
This commit is contained in:
parent
548fd466dd
commit
3e09db8fd1
|
@ -10,11 +10,11 @@ linters-settings:
|
|||
simplify: true
|
||||
goimports:
|
||||
local-prefixes: github.com/mattermost/mattermost-plugin-mscalendar
|
||||
golint:
|
||||
min-confidence: 0
|
||||
govet:
|
||||
check-shadowing: true
|
||||
enable-all: true
|
||||
disable:
|
||||
- fieldalignment
|
||||
misspell:
|
||||
locale: US
|
||||
|
||||
|
@ -22,27 +22,23 @@ linters:
|
|||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- deadcode
|
||||
# - errcheck
|
||||
# - goconst
|
||||
- gocritic
|
||||
- gofmt
|
||||
- goimports
|
||||
- golint
|
||||
# - gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- interfacer
|
||||
# - misspell
|
||||
- nakedret
|
||||
- revive
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
||||
|
||||
issues:
|
||||
|
|
|
@ -20,11 +20,11 @@ import (
|
|||
|
||||
// Handler handles commands
|
||||
type Command struct {
|
||||
MSCalendar mscalendar.MSCalendar
|
||||
Context *plugin.Context
|
||||
Args *model.CommandArgs
|
||||
ChannelID string
|
||||
Config *config.Config
|
||||
MSCalendar mscalendar.MSCalendar
|
||||
ChannelID string
|
||||
}
|
||||
|
||||
func getNotConnectedText() string {
|
||||
|
|
|
@ -8,25 +8,22 @@ type StoredConfig struct {
|
|||
OAuth2Authority string
|
||||
OAuth2ClientID string
|
||||
OAuth2ClientSecret string
|
||||
|
||||
bot.Config
|
||||
EnableStatusSync bool
|
||||
EnableDailySummary bool
|
||||
|
||||
bot.Config
|
||||
}
|
||||
|
||||
// Config represents the the metadata handed to all request runners (command,
|
||||
// http).
|
||||
type Config struct {
|
||||
StoredConfig
|
||||
|
||||
PluginID string
|
||||
BuildDate string
|
||||
BuildHash string
|
||||
BuildHashShort string
|
||||
MattermostSiteHostname string
|
||||
MattermostSiteURL string
|
||||
PluginID string
|
||||
PluginURL string
|
||||
PluginURLPath string
|
||||
PluginVersion string
|
||||
StoredConfig
|
||||
}
|
||||
|
|
|
@ -16,16 +16,16 @@ import (
|
|||
)
|
||||
|
||||
type JobManager struct {
|
||||
registeredJobs sync.Map
|
||||
activeJobs sync.Map
|
||||
env mscalendar.Env
|
||||
papi cluster.JobPluginAPI
|
||||
registeredJobs sync.Map
|
||||
activeJobs sync.Map
|
||||
}
|
||||
|
||||
type RegisteredJob struct {
|
||||
work func(env mscalendar.Env)
|
||||
id string
|
||||
interval time.Duration
|
||||
work func(env mscalendar.Env)
|
||||
}
|
||||
|
||||
var scheduleFunc = func(api cluster.JobPluginAPI, id string, wait cluster.NextWaitInterval, cb func()) (io.Closer, error) {
|
||||
|
@ -33,9 +33,9 @@ var scheduleFunc = func(api cluster.JobPluginAPI, id string, wait cluster.NextWa
|
|||
}
|
||||
|
||||
type activeJob struct {
|
||||
RegisteredJob
|
||||
ScheduledJob io.Closer
|
||||
Context context.Context
|
||||
RegisteredJob
|
||||
}
|
||||
|
||||
func newActiveJob(ctx context.Context, rj RegisteredJob, sched io.Closer) *activeJob {
|
||||
|
|
|
@ -27,13 +27,13 @@ func TestSyncStatusAll(t *testing.T) {
|
|||
busyEvent := &remote.Event{ICalUID: "event_id", Start: remote.NewDateTime(moment, "UTC"), ShowAs: "busy"}
|
||||
|
||||
for name, tc := range map[string]struct {
|
||||
remoteEvents []*remote.Event
|
||||
apiError *remote.APIError
|
||||
activeEvents []string
|
||||
currentStatus string
|
||||
currentStatusManual bool
|
||||
newStatus string
|
||||
remoteEvents []*remote.Event
|
||||
activeEvents []string
|
||||
eventsToStore []string
|
||||
currentStatusManual bool
|
||||
shouldLogError bool
|
||||
getConfirmation bool
|
||||
}{
|
||||
|
@ -170,8 +170,8 @@ func TestSyncStatusAll(t *testing.T) {
|
|||
|
||||
func TestSyncStatusUserConfig(t *testing.T) {
|
||||
for name, tc := range map[string]struct {
|
||||
settings store.Settings
|
||||
runAssertions func(deps *Dependencies, client remote.Client)
|
||||
settings store.Settings
|
||||
}{
|
||||
"UpdateStatus disabled": {
|
||||
settings: store.Settings{
|
||||
|
@ -231,9 +231,9 @@ func TestSyncStatusUserConfig(t *testing.T) {
|
|||
|
||||
func TestReminders(t *testing.T) {
|
||||
for name, tc := range map[string]struct {
|
||||
apiError *remote.APIError
|
||||
remoteEvents []*remote.Event
|
||||
numReminders int
|
||||
apiError *remote.APIError
|
||||
shouldLogError bool
|
||||
}{
|
||||
"Most common case, no remote events. No reminder.": {
|
||||
|
|
|
@ -21,9 +21,9 @@ import (
|
|||
|
||||
func TestProcessAllDailySummary(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
runAssertions func(deps *Dependencies, client remote.Client)
|
||||
name string
|
||||
err string
|
||||
runAssertions func(deps *Dependencies, client remote.Client)
|
||||
}{
|
||||
{
|
||||
name: "Error fetching index",
|
||||
|
@ -210,9 +210,9 @@ Wednesday February 12
|
|||
func TestShouldPostDailySummary(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
enabled bool
|
||||
postTime string
|
||||
timeZone string
|
||||
enabled bool
|
||||
shouldRun bool
|
||||
shouldError bool
|
||||
}{
|
||||
|
|
|
@ -48,9 +48,9 @@ const (
|
|||
ResponseNone = "notResponded"
|
||||
)
|
||||
|
||||
var importantNotificationChanges []string = []string{FieldSubject, FieldWhen}
|
||||
var importantNotificationChanges = []string{FieldSubject, FieldWhen}
|
||||
|
||||
var notificationFieldOrder []string = []string{
|
||||
var notificationFieldOrder = []string{
|
||||
FieldWhen,
|
||||
FieldLocation,
|
||||
FieldAttendees,
|
||||
|
@ -266,7 +266,9 @@ func (processor *notificationProcessor) updatedEventSlackAttachment(n *remote.No
|
|||
return false, nil
|
||||
}
|
||||
|
||||
allChanges := append(added, updated...)
|
||||
var allChanges []string
|
||||
allChanges = append(allChanges, added...)
|
||||
allChanges = append(allChanges, updated...)
|
||||
allChanges = append(allChanges, deleted...)
|
||||
|
||||
hasImportantChanges := false
|
||||
|
|
|
@ -92,10 +92,10 @@ func newTestNotification(clientState string, recommendRenew bool) *remote.Notifi
|
|||
|
||||
func TestProcessNotification(t *testing.T) {
|
||||
tcs := []struct {
|
||||
name string
|
||||
expectedError string
|
||||
notification *remote.Notification
|
||||
priorEvent *remote.Event
|
||||
name string
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
name: "incoming ClientState matches stored ClientState",
|
||||
|
|
|
@ -78,11 +78,11 @@ func TestInitOAuth2(t *testing.T) {
|
|||
defer ctrl.Finish()
|
||||
|
||||
tcs := []struct {
|
||||
setup func(dependencies *Dependencies)
|
||||
name string
|
||||
mattermostUserID string
|
||||
setup func(dependencies *Dependencies)
|
||||
expectError bool
|
||||
expectURL string
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
name: "MM user already connected",
|
||||
|
|
|
@ -12,15 +12,15 @@ import (
|
|||
)
|
||||
|
||||
type dailySummarySetting struct {
|
||||
store settingspanel.SettingStore
|
||||
getTimezone func(userID string) (string, error)
|
||||
title string
|
||||
dependsOn string
|
||||
description string
|
||||
id string
|
||||
dependsOn string
|
||||
optionsH []string
|
||||
optionsM []string
|
||||
optionsAPM []string
|
||||
store settingspanel.SettingStore
|
||||
getTimezone func(userID string) (string, error)
|
||||
}
|
||||
|
||||
func NewDailySummarySetting(inStore settingspanel.SettingStore, getTimezone func(userID string) (string, error)) settingspanel.Setting {
|
||||
|
|
|
@ -9,11 +9,11 @@ import (
|
|||
)
|
||||
|
||||
type notificationSetting struct {
|
||||
getCal func(string) MSCalendar
|
||||
title string
|
||||
description string
|
||||
id string
|
||||
dependsOn string
|
||||
getCal func(string) MSCalendar
|
||||
}
|
||||
|
||||
func NewNotificationsSetting(getCal func(string) MSCalendar) settingspanel.Setting {
|
||||
|
|
|
@ -24,9 +24,9 @@ type Users interface {
|
|||
}
|
||||
|
||||
type User struct {
|
||||
MattermostUserID string
|
||||
*store.User
|
||||
MattermostUser *model.User
|
||||
MattermostUser *model.User
|
||||
MattermostUserID string
|
||||
}
|
||||
|
||||
func NewUser(mattermostUserID string) *User {
|
||||
|
@ -61,7 +61,7 @@ func (m *mscalendar) ExpandRemoteUser(user *User) error {
|
|||
if user.User == nil {
|
||||
storedUser, err := m.Store.LoadUser(user.MattermostUserID)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "It looks like your Mattermost account is not connected to a Microsoft account. Please connect your account using `/mscalendar connect`.")
|
||||
return errors.Wrap(err, "It looks like your Mattermost account is not connected to a Microsoft account. Please connect your account using `/mscalendar connect`.") //nolint:revive
|
||||
}
|
||||
user.User = storedUser
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
)
|
||||
|
||||
type WelcomeFlow struct {
|
||||
steps []flow.Step
|
||||
url string
|
||||
controller bot.FlowController
|
||||
onFlowDone func(userID string)
|
||||
url string
|
||||
steps []flow.Step
|
||||
}
|
||||
|
||||
func NewWelcomeFlow(bot bot.FlowController, welcomer Welcomer) *WelcomeFlow {
|
||||
|
|
|
@ -8,21 +8,21 @@ import (
|
|||
)
|
||||
|
||||
type Calendar struct {
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Events []Event `json:"events,omitempty"`
|
||||
CalendarView []Event `json:"calendarView,omitempty"`
|
||||
Owner *User `json:"owner,omitempty"`
|
||||
}
|
||||
|
||||
type ViewCalendarParams struct {
|
||||
RemoteUserID string
|
||||
StartTime time.Time
|
||||
EndTime time.Time
|
||||
RemoteUserID string
|
||||
}
|
||||
|
||||
type ViewCalendarResponse struct {
|
||||
Error *APIError
|
||||
RemoteUserID string
|
||||
Events []*Event
|
||||
Error *APIError
|
||||
}
|
||||
|
|
|
@ -4,25 +4,25 @@
|
|||
package remote
|
||||
|
||||
type Event struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Start *DateTime `json:"start,omitempty"`
|
||||
Location *Location `json:"location,omitempty"`
|
||||
End *DateTime `json:"end,omitempty"`
|
||||
Organizer *Attendee `json:"organizer,omitempty"`
|
||||
Body *ItemBody `json:"Body,omitempty"`
|
||||
ResponseStatus *EventResponseStatus `json:"responseStatus,omitempty"`
|
||||
Importance string `json:"importance,omitempty"`
|
||||
ICalUID string `json:"iCalUId,omitempty"`
|
||||
Subject string `json:"subject,omitempty"`
|
||||
BodyPreview string `json:"bodyPreview,omitempty"`
|
||||
Body *ItemBody `json:"Body,omitempty"`
|
||||
Importance string `json:"importance,omitempty"`
|
||||
IsAllDay bool `json:"isAllDay,omitempty"`
|
||||
IsCancelled bool `json:"isCancelled,omitempty"`
|
||||
IsOrganizer bool `json:"isOrganizer,omitempty"`
|
||||
ResponseRequested bool `json:"responseRequested,omitempty"`
|
||||
ShowAs string `json:"showAs,omitempty"`
|
||||
Weblink string `json:"weblink,omitempty"`
|
||||
Start *DateTime `json:"start,omitempty"`
|
||||
End *DateTime `json:"end,omitempty"`
|
||||
ReminderMinutesBeforeStart int `json:"reminderMinutesBeforeStart,omitempty"`
|
||||
Location *Location `json:"location,omitempty"`
|
||||
ResponseStatus *EventResponseStatus `json:"responseStatus,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Attendees []*Attendee `json:"attendees,omitempty"`
|
||||
Organizer *Attendee `json:"organizer,omitempty"`
|
||||
ReminderMinutesBeforeStart int `json:"reminderMinutesBeforeStart,omitempty"`
|
||||
IsOrganizer bool `json:"isOrganizer,omitempty"`
|
||||
IsCancelled bool `json:"isCancelled,omitempty"`
|
||||
IsAllDay bool `json:"isAllDay,omitempty"`
|
||||
ResponseRequested bool `json:"responseRequested,omitempty"`
|
||||
}
|
||||
|
||||
type ItemBody struct {
|
||||
|
@ -56,7 +56,7 @@ type Coordinates struct {
|
|||
}
|
||||
|
||||
type Attendee struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Status *EventResponseStatus `json:"status,omitempty"`
|
||||
EmailAddress *EmailAddress `json:"emailAddress,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ package remote
|
|||
import "time"
|
||||
|
||||
type FindMeetingTimesParameters struct {
|
||||
Attendees []Attendee `json:"attendees,omitempty"`
|
||||
ReturnSuggestionReasons *bool `json:"returnSuggestionReasons,omitempty"`
|
||||
LocationConstraint *LocationConstraint `json:"locationConstraint,omitempty"`
|
||||
TimeConstraint *TimeConstraint `json:"timeConstraint,omitempty"`
|
||||
MeetingDuration *time.Duration `json:"meetingDuration,omitempty"`
|
||||
MaxCandidates *int `json:"maxCandidates,omitempty"`
|
||||
IsOrganizerOptional *bool `json:"isOrganizerOptional,omitempty"`
|
||||
ReturnSuggestionReasons *bool `json:"returnSuggestionReasons,omitempty"`
|
||||
MinimumAttendeePercentage *float64 `json:"minimumAttendeePercentage,omitempty"`
|
||||
Attendees []Attendee `json:"attendees,omitempty"`
|
||||
}
|
||||
|
||||
type TimeConstraint struct {
|
||||
|
@ -21,13 +21,13 @@ type TimeConstraint struct {
|
|||
TimeSlots []TimeSlot `json:"timeSlots,omitempty"`
|
||||
}
|
||||
type MeetingTimeSuggestion struct {
|
||||
MeetingTimeSlot *TimeSlot
|
||||
SuggestionReason string `json:"suggestionReason"`
|
||||
OrganizerAvailability string `json:"organizerAvailability"`
|
||||
Locations []*Location
|
||||
AttendeeAvailability []*AttendeeAvailability
|
||||
Confidence float32 `json:"confidence"`
|
||||
Locations []*Location
|
||||
MeetingTimeSlot *TimeSlot
|
||||
Order int32 `json:"order"`
|
||||
OrganizerAvailability string `json:"organizerAvailability"`
|
||||
SuggestionReason string `json:"suggestionReason"`
|
||||
Order int32 `json:"order"`
|
||||
}
|
||||
|
||||
type AttendeeAvailability struct {
|
||||
|
@ -36,8 +36,8 @@ type AttendeeAvailability struct {
|
|||
}
|
||||
|
||||
type MeetingTimeSuggestionResults struct {
|
||||
MeetingTimeSuggestions []*MeetingTimeSuggestion `json:"meetingTimeSuggestions"`
|
||||
EmptySuggestionReason string `json:"emptySuggestionReason"`
|
||||
MeetingTimeSuggestions []*MeetingTimeSuggestion `json:"meetingTimeSuggestions"`
|
||||
}
|
||||
|
||||
type TimeSlot struct {
|
||||
|
@ -46,9 +46,9 @@ type TimeSlot struct {
|
|||
}
|
||||
|
||||
type LocationConstraint struct {
|
||||
Locations []LocationConstraintItem `json:"locations,omitempty"`
|
||||
IsRequired *bool `json:"isRequired,omitempty"`
|
||||
SuggestLocation *bool `json:"suggestLocation,omitempty"`
|
||||
Locations []LocationConstraintItem `json:"locations,omitempty"`
|
||||
}
|
||||
|
||||
type LocationConstraintItem struct {
|
||||
|
|
|
@ -10,11 +10,11 @@ import (
|
|||
const maxNumRequestsPerBatch = 20
|
||||
|
||||
type singleRequest struct {
|
||||
Body interface{} `json:"body"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Method string `json:"method"`
|
||||
Body interface{} `json:"body"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
}
|
||||
|
||||
type fullBatchRequest struct {
|
||||
|
|
|
@ -14,15 +14,15 @@ import (
|
|||
)
|
||||
|
||||
type calendarViewResponse struct {
|
||||
Value []*remote.Event `json:"value,omitempty"`
|
||||
Error *remote.APIError `json:"error,omitempty"`
|
||||
Value []*remote.Event `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type calendarViewSingleResponse struct {
|
||||
ID string `json:"id"`
|
||||
Status int `json:"status"`
|
||||
Body calendarViewResponse `json:"body"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
ID string `json:"id"`
|
||||
Body calendarViewResponse `json:"body"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
type calendarViewBatchResponse struct {
|
||||
|
|
|
@ -9,15 +9,15 @@ import (
|
|||
)
|
||||
|
||||
type getScheduleResponse struct {
|
||||
Value []*remote.ScheduleInformation `json:"value,omitempty"`
|
||||
Error *remote.APIError `json:"error,omitempty"`
|
||||
Value []*remote.ScheduleInformation `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type getScheduleSingleResponse struct {
|
||||
ID string `json:"id"`
|
||||
Status int `json:"status"`
|
||||
Body getScheduleResponse `json:"body"`
|
||||
Headers map[string]string `json:"headers"`
|
||||
ID string `json:"id"`
|
||||
Body getScheduleResponse `json:"body"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
type getScheduleBatchResponse struct {
|
||||
|
@ -25,13 +25,13 @@ type getScheduleBatchResponse struct {
|
|||
}
|
||||
|
||||
type getScheduleRequestParams struct {
|
||||
// List of emails of users that we want to check
|
||||
Schedules []string `json:"schedules"`
|
||||
|
||||
// Overall start and end of entire search window
|
||||
StartTime *remote.DateTime `json:"startTime"`
|
||||
EndTime *remote.DateTime `json:"endTime"`
|
||||
|
||||
// List of emails of users that we want to check
|
||||
Schedules []string `json:"schedules"`
|
||||
|
||||
/*
|
||||
Size of each chunk of time we want to check
|
||||
This can be equal to end - start if we want, or we can get more granular results by making it shorter.
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
type AuthResponse struct {
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
AccessToken string `json:"access_token"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
}
|
||||
|
||||
func (c *client) GetSuperuserToken() (string, error) {
|
||||
|
|
|
@ -4,12 +4,27 @@
|
|||
package remote
|
||||
|
||||
type Notification struct {
|
||||
Webhook interface{}
|
||||
|
||||
// Notification data
|
||||
Subscription *Subscription
|
||||
SubscriptionCreator *User
|
||||
Event *Event
|
||||
|
||||
// ClientState from the webhook. The handler is to validate against its own
|
||||
// persistent secret.
|
||||
ClientState string
|
||||
|
||||
// Notification type
|
||||
ChangeType string
|
||||
|
||||
// The (remote) subscription ID the notification is for
|
||||
SubscriptionID string
|
||||
|
||||
// Remote-specific data: full raw JSON of the webhook, and the decoded
|
||||
// backend-specific struct.
|
||||
WebhookRawData []byte
|
||||
|
||||
// Set if subscription renewal is recommended. The date/time logic is
|
||||
// internal to the remote implementation. The handler is to call
|
||||
// RenewSubscription() as applicable, with the appropriate user credentials.
|
||||
|
@ -19,18 +34,4 @@ type Notification struct {
|
|||
// handler is to call GetNofiticationData(), with the appropriate user
|
||||
// credentials.
|
||||
IsBare bool
|
||||
|
||||
// ClientState from the webhook. The handler is to validate against its own
|
||||
// persistent secret.
|
||||
ClientState string
|
||||
|
||||
// Remote-specific data: full raw JSON of the webhook, and the decoded
|
||||
// backend-specific struct.
|
||||
WebhookRawData []byte
|
||||
Webhook interface{}
|
||||
|
||||
// Notification data
|
||||
Subscription *Subscription
|
||||
SubscriptionCreator *User
|
||||
Event *Event
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ type ScheduleUserInfo struct {
|
|||
}
|
||||
|
||||
type ScheduleItem struct {
|
||||
IsPrivate bool
|
||||
Start *DateTime
|
||||
End *DateTime
|
||||
Status string
|
||||
Subject string
|
||||
Location string
|
||||
Start *DateTime
|
||||
End *DateTime
|
||||
IsPrivate bool
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ type User struct {
|
|||
}
|
||||
|
||||
type WorkingHours struct {
|
||||
DaysOfWeek []string `json:"daysOfWeek"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
TimeZone struct {
|
||||
StartTime string `json:"startTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
TimeZone struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
DaysOfWeek []string `json:"daysOfWeek"`
|
||||
}
|
||||
|
||||
type MailboxSettings struct {
|
||||
|
|
|
@ -19,8 +19,8 @@ const ttlAfterEventEnd = 30 * 24 * time.Hour // 30 days
|
|||
const defaultEventTTL = 30 * 24 * time.Hour // 30 days
|
||||
|
||||
type Event struct {
|
||||
PluginVersion string
|
||||
Remote *remote.Event
|
||||
PluginVersion string
|
||||
}
|
||||
|
||||
type EventStore interface {
|
||||
|
|
|
@ -35,30 +35,30 @@ type UserShort struct {
|
|||
}
|
||||
|
||||
type User struct {
|
||||
PluginVersion string
|
||||
Remote *remote.User
|
||||
MattermostUserID string
|
||||
OAuth2Token *oauth2.Token
|
||||
Settings Settings `json:"mattermostSettings,omitempty"`
|
||||
ActiveEvents []string `json:"events"`
|
||||
Remote *remote.User
|
||||
OAuth2Token *oauth2.Token
|
||||
PluginVersion string
|
||||
MattermostUserID string
|
||||
LastStatus string
|
||||
WelcomeFlowStatus WelcomeFlowStatus `json:"mattermostFlags,omitempty"`
|
||||
ActiveEvents []string `json:"events"`
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
DailySummary *DailySummaryUserSettings
|
||||
EventSubscriptionID string
|
||||
UpdateStatus bool
|
||||
GetConfirmation bool
|
||||
ReceiveReminders bool
|
||||
ReceiveNotificationsDuringMeeting bool
|
||||
DailySummary *DailySummaryUserSettings
|
||||
}
|
||||
|
||||
type DailySummaryUserSettings struct {
|
||||
Enable bool `json:"enable"`
|
||||
PostTime string `json:"post_time"` // Kitchen format, i.e. 8:30AM
|
||||
Timezone string `json:"tz"` // Timezone in MSCal when PostTime is set/updated
|
||||
LastPostTime string `json:"last_post_time"`
|
||||
Enable bool `json:"enable"`
|
||||
}
|
||||
|
||||
type WelcomeFlowStatus struct {
|
||||
|
@ -207,7 +207,10 @@ func (s *pluginStore) StoreUserInIndex(user *User) error {
|
|||
|
||||
for i, u := range userIndex {
|
||||
if u.MattermostUserID == user.MattermostUserID && u.RemoteID == user.Remote.ID {
|
||||
result := append(userIndex[:i], newUser)
|
||||
var result UserIndex
|
||||
result = append(result, userIndex[:i]...)
|
||||
result = append(result, newUser)
|
||||
|
||||
return append(result, userIndex[i+1:]...), nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,16 +25,15 @@ type Bot interface {
|
|||
}
|
||||
|
||||
type bot struct {
|
||||
Config
|
||||
pluginAPI plugin.API
|
||||
pluginHelpers plugin.Helpers
|
||||
mattermostUserID string
|
||||
displayName string
|
||||
flow flow.Flow
|
||||
flowStore flow.Store
|
||||
logContext LogContext
|
||||
pluginURL string
|
||||
|
||||
flow flow.Flow
|
||||
flowStore flow.Store
|
||||
mattermostUserID string
|
||||
displayName string
|
||||
Config
|
||||
}
|
||||
|
||||
func New(api plugin.API, helpers plugin.Helpers, pluginURL string) Bot {
|
||||
|
|
|
@ -62,32 +62,32 @@ func TestParseByteSize(t *testing.T) {
|
|||
|
||||
func TestByteSizeString(t *testing.T) {
|
||||
tests := []struct {
|
||||
n ByteSize
|
||||
want string
|
||||
n ByteSize
|
||||
}{
|
||||
{0, "0"},
|
||||
{1, "1b"},
|
||||
{999, "999b"},
|
||||
{1000, "1,000b"},
|
||||
{1023, "1,023b"},
|
||||
{1024, "1Kb"},
|
||||
{12345, "12.1Kb"},
|
||||
{12851, "12.5Kb"}, // 12.54980
|
||||
{12852, "12.6Kb"}, // 12.55078
|
||||
{123456, "120.6Kb"},
|
||||
{1234567, "1.2Mb"},
|
||||
{12345678, "11.8Mb"},
|
||||
{123456789, "117.7Mb"},
|
||||
{1234567890, "1.1Gb"},
|
||||
{12345678900, "11.5Gb"},
|
||||
{123456789000, "115Gb"},
|
||||
{1234567890000, "1.1Tb"},
|
||||
{12345678900000, "11.2Tb"},
|
||||
{123456789000000, "112.3Tb"},
|
||||
{1234567890000000, "1,122.8Tb"},
|
||||
{12345678900000000, "11,228.3Tb"},
|
||||
{123456789000000000, "112,283.3Tb"},
|
||||
{1234567890000000000, "n/a"},
|
||||
{"0", 0},
|
||||
{"1b", 1},
|
||||
{"999b", 999},
|
||||
{"1,000b", 1000},
|
||||
{"1,023b", 1023},
|
||||
{"1Kb", 1024},
|
||||
{"12.1Kb", 12345},
|
||||
{"12.5Kb", 12851}, // 12.54980
|
||||
{"12.6Kb", 12852}, // 12.55078
|
||||
{"120.6Kb", 123456},
|
||||
{"1.2Mb", 1234567},
|
||||
{"11.8Mb", 12345678},
|
||||
{"117.7Mb", 123456789},
|
||||
{"1.1Gb", 1234567890},
|
||||
{"11.5Gb", 12345678900},
|
||||
{"115Gb", 123456789000},
|
||||
{"1.1Tb", 1234567890000},
|
||||
{"11.2Tb", 12345678900000},
|
||||
{"112.3Tb", 123456789000000},
|
||||
{"1,122.8Tb", 1234567890000000},
|
||||
{"11,228.3Tb", 12345678900000000},
|
||||
{"112,283.3Tb", 123456789000000000},
|
||||
{"n/a", 1234567890000000000},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(fmt.Sprintf("%d", tt.n), func(t *testing.T) {
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
|
||||
type LimitReadCloser struct {
|
||||
ReadCloser io.ReadCloser
|
||||
OnClose func(*LimitReadCloser) error
|
||||
TotalRead utils.ByteSize
|
||||
Limit utils.ByteSize
|
||||
OnClose func(*LimitReadCloser) error
|
||||
}
|
||||
|
||||
func (r *LimitReadCloser) Read(data []byte) (int, error) {
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
)
|
||||
|
||||
type boolSetting struct {
|
||||
store SettingStore
|
||||
title string
|
||||
description string
|
||||
id string
|
||||
dependsOn string
|
||||
store SettingStore
|
||||
}
|
||||
|
||||
func NewBoolSetting(id string, title string, description string, dependsOn string, store SettingStore) Setting {
|
||||
|
|
|
@ -8,12 +8,12 @@ import (
|
|||
)
|
||||
|
||||
type optionSetting struct {
|
||||
store SettingStore
|
||||
title string
|
||||
description string
|
||||
id string
|
||||
dependsOn string
|
||||
options []string
|
||||
store SettingStore
|
||||
}
|
||||
|
||||
func NewOptionSetting(id string, title string, description string, dependsOn string, options []string, store SettingStore) Setting {
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
)
|
||||
|
||||
type readOnlySetting struct {
|
||||
store SettingStore
|
||||
title string
|
||||
description string
|
||||
id string
|
||||
dependsOn string
|
||||
store SettingStore
|
||||
}
|
||||
|
||||
func NewReadOnlySetting(id string, title string, description string, dependsOn string, store SettingStore) Setting {
|
||||
|
|
|
@ -41,13 +41,13 @@ type PanelStore interface {
|
|||
}
|
||||
|
||||
type panel struct {
|
||||
settings map[string]Setting
|
||||
settingKeys []string
|
||||
poster bot.Poster
|
||||
logger bot.Logger
|
||||
store PanelStore
|
||||
settings map[string]Setting
|
||||
settingHandler string
|
||||
pluginURL string
|
||||
settingKeys []string
|
||||
}
|
||||
|
||||
func NewSettingsPanel(settings []Setting, poster bot.Poster, logger bot.Logger, store PanelStore, settingHandler, pluginURL string) Panel {
|
||||
|
|
|
@ -13,20 +13,20 @@ type Client interface {
|
|||
}
|
||||
|
||||
type Track struct {
|
||||
Properties map[string]interface{}
|
||||
UserID string
|
||||
Event string
|
||||
Properties map[string]interface{}
|
||||
}
|
||||
|
||||
type tracker struct {
|
||||
client Client
|
||||
diagnosticID string
|
||||
logger bot.Logger
|
||||
serverVersion string
|
||||
pluginID string
|
||||
pluginVersion string
|
||||
telemetryShortName string
|
||||
diagnosticID string
|
||||
enabled bool
|
||||
logger bot.Logger
|
||||
}
|
||||
|
||||
func NewTracker(c Client, diagnosticID, serverVersion, pluginID, pluginVersion, telemetryShortName string, enableDiagnostics bool, logger bot.Logger) Tracker {
|
||||
|
|
Reference in New Issue