From e36f755db2198a96e2b87781f5f5432fcee092dd Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Thu, 4 Oct 2018 19:01:51 -0700 Subject: fix build --- .../vendor/github.com/McKael/madon/account.go | 430 -------- .../furrybb/vendor/github.com/McKael/madon/api.go | 137 --- .../furrybb/vendor/github.com/McKael/madon/app.go | 96 -- .../vendor/github.com/McKael/madon/favourites.go | 21 - .../vendor/github.com/McKael/madon/instance.go | 20 - .../vendor/github.com/McKael/madon/login.go | 88 -- .../vendor/github.com/McKael/madon/madon.go | 36 - .../vendor/github.com/McKael/madon/media.go | 75 -- .../github.com/McKael/madon/notifications.go | 47 - .../vendor/github.com/McKael/madon/report.go | 47 - .../vendor/github.com/McKael/madon/search.go | 30 - .../vendor/github.com/McKael/madon/status.go | 229 ----- .../vendor/github.com/McKael/madon/streams.go | 169 ---- .../vendor/github.com/McKael/madon/timelines.go | 46 - .../vendor/github.com/McKael/madon/types.go | 157 --- .../furrybb/vendor/github.com/Xe/gopreload/doc.go | 7 - .../vendor/github.com/Xe/gopreload/preload.go | 26 - mastodon/furrybb/vendor/github.com/Xe/ln/filter.go | 66 -- .../furrybb/vendor/github.com/Xe/ln/formatter.go | 110 --- mastodon/furrybb/vendor/github.com/Xe/ln/logger.go | 141 --- mastodon/furrybb/vendor/github.com/Xe/ln/stack.go | 44 - .../furrybb/vendor/github.com/caarlos0/env/env.go | 275 ------ .../vendor/github.com/google/gops/agent/agent.go | 237 ----- .../github.com/google/gops/internal/internal.go | 52 - .../vendor/github.com/google/gops/signal/signal.go | 35 - .../vendor/github.com/gorilla/websocket/client.go | 420 -------- .../github.com/gorilla/websocket/compression.go | 85 -- .../vendor/github.com/gorilla/websocket/conn.go | 1031 -------------------- .../github.com/gorilla/websocket/conn_read.go | 18 - .../gorilla/websocket/conn_read_legacy.go | 21 - .../vendor/github.com/gorilla/websocket/doc.go | 173 ---- .../vendor/github.com/gorilla/websocket/json.go | 55 -- .../vendor/github.com/gorilla/websocket/mask.go | 61 -- .../vendor/github.com/gorilla/websocket/server.go | 292 ------ .../vendor/github.com/gorilla/websocket/util.go | 214 ---- .../github.com/joho/godotenv/autoload/autoload.go | 15 - .../vendor/github.com/joho/godotenv/godotenv.go | 235 ----- .../vendor/github.com/kardianos/osext/osext.go | 33 - .../github.com/kardianos/osext/osext_plan9.go | 20 - .../github.com/kardianos/osext/osext_procfs.go | 36 - .../github.com/kardianos/osext/osext_sysctl.go | 126 --- .../github.com/kardianos/osext/osext_windows.go | 34 - .../furrybb/vendor/github.com/pkg/errors/errors.go | 269 ----- .../furrybb/vendor/github.com/pkg/errors/stack.go | 178 ---- .../vendor/github.com/sendgrid/rest/rest.go | 140 --- 45 files changed, 6077 deletions(-) delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/account.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/api.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/app.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/favourites.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/instance.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/login.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/madon.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/media.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/notifications.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/report.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/search.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/status.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/streams.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/timelines.go delete mode 100644 mastodon/furrybb/vendor/github.com/McKael/madon/types.go delete mode 100644 mastodon/furrybb/vendor/github.com/Xe/gopreload/doc.go delete mode 100644 mastodon/furrybb/vendor/github.com/Xe/gopreload/preload.go delete mode 100644 mastodon/furrybb/vendor/github.com/Xe/ln/filter.go delete mode 100644 mastodon/furrybb/vendor/github.com/Xe/ln/formatter.go delete mode 100644 mastodon/furrybb/vendor/github.com/Xe/ln/logger.go delete mode 100644 mastodon/furrybb/vendor/github.com/Xe/ln/stack.go delete mode 100644 mastodon/furrybb/vendor/github.com/caarlos0/env/env.go delete mode 100644 mastodon/furrybb/vendor/github.com/google/gops/agent/agent.go delete mode 100644 mastodon/furrybb/vendor/github.com/google/gops/internal/internal.go delete mode 100644 mastodon/furrybb/vendor/github.com/google/gops/signal/signal.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/client.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/compression.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/conn.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/conn_read.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/conn_read_legacy.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/doc.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/json.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/mask.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/server.go delete mode 100644 mastodon/furrybb/vendor/github.com/gorilla/websocket/util.go delete mode 100644 mastodon/furrybb/vendor/github.com/joho/godotenv/autoload/autoload.go delete mode 100644 mastodon/furrybb/vendor/github.com/joho/godotenv/godotenv.go delete mode 100644 mastodon/furrybb/vendor/github.com/kardianos/osext/osext.go delete mode 100644 mastodon/furrybb/vendor/github.com/kardianos/osext/osext_plan9.go delete mode 100644 mastodon/furrybb/vendor/github.com/kardianos/osext/osext_procfs.go delete mode 100644 mastodon/furrybb/vendor/github.com/kardianos/osext/osext_sysctl.go delete mode 100644 mastodon/furrybb/vendor/github.com/kardianos/osext/osext_windows.go delete mode 100644 mastodon/furrybb/vendor/github.com/pkg/errors/errors.go delete mode 100644 mastodon/furrybb/vendor/github.com/pkg/errors/stack.go delete mode 100644 mastodon/furrybb/vendor/github.com/sendgrid/rest/rest.go (limited to 'mastodon/furrybb/vendor/github.com') diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/account.go b/mastodon/furrybb/vendor/github.com/McKael/madon/account.go deleted file mode 100644 index e96aa59..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/account.go +++ /dev/null @@ -1,430 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "bytes" - "encoding/base64" - "encoding/json" - "fmt" - "mime/multipart" - "net/http" - "os" - "strconv" - "strings" - - "github.com/sendgrid/rest" -) - -// getAccountsOptions contains option fields for POST and DELETE API calls -type getAccountsOptions struct { - // The ID is used for most commands - ID int - - // The following fields are used when searching for accounts - Q string - Limit int -} - -// getSingleAccount returns an account entity -// The operation 'op' can be "account", "verify_credentials", "follow", -// "unfollow", "block", "unblock", "mute", "unmute", -// "follow_requests/authorize" or // "follow_requests/reject". -// The id is optional and depends on the operation. -func (mc *Client) getSingleAccount(op string, id int) (*Account, error) { - var endPoint string - method := rest.Get - strID := strconv.Itoa(id) - - switch op { - case "account": - endPoint = "accounts/" + strID - case "verify_credentials": - endPoint = "accounts/verify_credentials" - case "follow", "unfollow", "block", "unblock", "mute", "unmute": - endPoint = "accounts/" + strID + "/" + op - method = rest.Post - case "follow_requests/authorize", "follow_requests/reject": - // The documentation is incorrect, the endpoint actually - // is "follow_requests/:id/{authorize|reject}" - endPoint = op[:16] + strID + "/" + op[16:] - method = rest.Post - default: - return nil, ErrInvalidParameter - } - - var account Account - if err := mc.apiCall(endPoint, method, nil, &account); err != nil { - return nil, err - } - return &account, nil -} - -// getMultipleAccounts returns a list of account entities -// The operation 'op' can be "followers", "following", "search", "blocks", -// "mutes", "follow_requests". -// The id is optional and depends on the operation. -func (mc *Client) getMultipleAccounts(op string, opts *getAccountsOptions) ([]Account, error) { - var endPoint string - - switch op { - case "followers", "following": - if opts == nil || opts.ID < 1 { - return []Account{}, ErrInvalidID - } - endPoint = "accounts/" + strconv.Itoa(opts.ID) + "/" + op - case "follow_requests", "blocks", "mutes": - endPoint = op - case "search": - if opts == nil || opts.Q == "" { - return []Account{}, ErrInvalidParameter - } - endPoint = "accounts/" + op - default: - return nil, ErrInvalidParameter - } - - // Handle target-specific query parameters - params := make(apiCallParams) - if op == "search" { - params["q"] = opts.Q - if opts.Limit > 0 { - params["limit"] = strconv.Itoa(opts.Limit) - } - } - - var accounts []Account - if err := mc.apiCall(endPoint, rest.Get, params, &accounts); err != nil { - return nil, err - } - return accounts, nil -} - -// GetAccount returns an account entity -// The returned value can be nil if there is an error or if the -// requested ID does not exist. -func (mc *Client) GetAccount(accountID int) (*Account, error) { - account, err := mc.getSingleAccount("account", accountID) - if err != nil { - return nil, err - } - if account != nil && account.ID == 0 { - return nil, ErrEntityNotFound - } - return account, nil -} - -// GetCurrentAccount returns the current user account -func (mc *Client) GetCurrentAccount() (*Account, error) { - account, err := mc.getSingleAccount("verify_credentials", 0) - if err != nil { - return nil, err - } - if account != nil && account.ID == 0 { - return nil, ErrEntityNotFound - } - return account, nil -} - -// GetAccountFollowers returns the list of accounts following a given account -func (mc *Client) GetAccountFollowers(accountID int) ([]Account, error) { - o := &getAccountsOptions{ID: accountID} - return mc.getMultipleAccounts("followers", o) -} - -// GetAccountFollowing returns the list of accounts a given account is following -func (mc *Client) GetAccountFollowing(accountID int) ([]Account, error) { - o := &getAccountsOptions{ID: accountID} - return mc.getMultipleAccounts("following", o) -} - -// FollowAccount follows an account -func (mc *Client) FollowAccount(accountID int) error { - account, err := mc.getSingleAccount("follow", accountID) - if err != nil { - return err - } - if account != nil && account.ID != accountID { - return ErrEntityNotFound - } - return nil -} - -// UnfollowAccount unfollows an account -func (mc *Client) UnfollowAccount(accountID int) error { - account, err := mc.getSingleAccount("unfollow", accountID) - if err != nil { - return err - } - if account != nil && account.ID != accountID { - return ErrEntityNotFound - } - return nil -} - -// FollowRemoteAccount follows a remote account -// The parameter 'uri' is a URI (e.mc. "username@domain"). -func (mc *Client) FollowRemoteAccount(uri string) (*Account, error) { - if uri == "" { - return nil, ErrInvalidID - } - - params := make(apiCallParams) - params["uri"] = uri - - var account Account - if err := mc.apiCall("follows", rest.Post, params, &account); err != nil { - return nil, err - } - if account.ID == 0 { - return nil, ErrEntityNotFound - } - return &account, nil -} - -// BlockAccount blocks an account -func (mc *Client) BlockAccount(accountID int) error { - account, err := mc.getSingleAccount("block", accountID) - if err != nil { - return err - } - if account != nil && account.ID != accountID { - return ErrEntityNotFound - } - return nil -} - -// UnblockAccount unblocks an account -func (mc *Client) UnblockAccount(accountID int) error { - account, err := mc.getSingleAccount("unblock", accountID) - if err != nil { - return err - } - if account != nil && account.ID != accountID { - return ErrEntityNotFound - } - return nil -} - -// MuteAccount mutes an account -func (mc *Client) MuteAccount(accountID int) error { - account, err := mc.getSingleAccount("mute", accountID) - if err != nil { - return err - } - if account != nil && account.ID != accountID { - return ErrEntityNotFound - } - return nil -} - -// UnmuteAccount unmutes an account -func (mc *Client) UnmuteAccount(accountID int) error { - account, err := mc.getSingleAccount("unmute", accountID) - if err != nil { - return err - } - if account != nil && account.ID != accountID { - return ErrEntityNotFound - } - return nil -} - -// SearchAccounts returns a list of accounts matching the query string -// The limit parameter is optional (can be 0). -func (mc *Client) SearchAccounts(query string, limit int) ([]Account, error) { - o := &getAccountsOptions{Q: query, Limit: limit} - return mc.getMultipleAccounts("search", o) -} - -// GetBlockedAccounts returns the list of blocked accounts -func (mc *Client) GetBlockedAccounts() ([]Account, error) { - return mc.getMultipleAccounts("blocks", nil) -} - -// GetMutedAccounts returns the list of muted accounts -func (mc *Client) GetMutedAccounts() ([]Account, error) { - return mc.getMultipleAccounts("mutes", nil) -} - -// GetAccountFollowRequests returns the list of follow requests accounts -func (mc *Client) GetAccountFollowRequests() ([]Account, error) { - return mc.getMultipleAccounts("follow_requests", nil) -} - -// GetAccountRelationships returns a list of relationship entities for the given accounts -func (mc *Client) GetAccountRelationships(accountIDs []int) ([]Relationship, error) { - if len(accountIDs) < 1 { - return nil, ErrInvalidID - } - - params := make(apiCallParams) - for i, id := range accountIDs { - if id < 1 { - return nil, ErrInvalidID - } - qID := fmt.Sprintf("id[%d]", i+1) - params[qID] = strconv.Itoa(id) - } - - var rl []Relationship - if err := mc.apiCall("accounts/relationships", rest.Get, params, &rl); err != nil { - return nil, err - } - return rl, nil -} - -// GetAccountStatuses returns a list of status entities for the given account -// If onlyMedia is true, returns only statuses that have media attachments. -// If excludeReplies is true, skip statuses that reply to other statuses. -func (mc *Client) GetAccountStatuses(accountID int, onlyMedia, excludeReplies bool) ([]Status, error) { - if accountID < 1 { - return nil, ErrInvalidID - } - - endPoint := "accounts/" + strconv.Itoa(accountID) + "/" + "statuses" - params := make(apiCallParams) - if onlyMedia { - params["only_media"] = "true" - } - if excludeReplies { - params["exclude_replies"] = "true" - } - - var sl []Status - if err := mc.apiCall(endPoint, rest.Get, params, &sl); err != nil { - return nil, err - } - return sl, nil -} - -// FollowRequestAuthorize authorizes or rejects an account follow-request -func (mc *Client) FollowRequestAuthorize(accountID int, authorize bool) error { - endPoint := "follow_requests/reject" - if authorize { - endPoint = "follow_requests/authorize" - } - _, err := mc.getSingleAccount(endPoint, accountID) - return err -} - -// UpdateAccount updates the connected user's account data -// The fields avatar & headerImage can contain base64-encoded images; if -// they do not (that is; if they don't contain ";base64,"), they are considered -// as file paths and their content will be encoded. -// All fields can be nil, in which case they are not updated. -// displayName and note can be set to "" to delete previous values; -// I'm not sure images can be deleted -- only replaced AFAICS. -func (mc *Client) UpdateAccount(displayName, note, avatar, headerImage *string) (*Account, error) { - const endPoint = "accounts/update_credentials" - params := make(apiCallParams) - - if displayName != nil { - params["display_name"] = *displayName - } - if note != nil { - params["note"] = *note - } - - var err error - avatar, err = fileToBase64(avatar, nil) - if err != nil { - return nil, err - } - headerImage, err = fileToBase64(headerImage, nil) - if err != nil { - return nil, err - } - - var formBuf bytes.Buffer - w := multipart.NewWriter(&formBuf) - - if avatar != nil { - w.WriteField("avatar", *avatar) - } - if headerImage != nil { - w.WriteField("header", *headerImage) - } - w.Close() - - // Prepare the request - req, err := mc.prepareRequest(endPoint, rest.Patch, params) - if err != nil { - return nil, fmt.Errorf("prepareRequest failed: %s", err.Error()) - } - req.Headers["Content-Type"] = w.FormDataContentType() - req.Body = formBuf.Bytes() - - // Make API call - r, err := restAPI(req) - if err != nil { - return nil, fmt.Errorf("account update failed: %s", err.Error()) - } - - // Check for error reply - var errorResult Error - if err := json.Unmarshal([]byte(r.Body), &errorResult); err == nil { - // The empty object is not an error - if errorResult.Text != "" { - return nil, fmt.Errorf("%s", errorResult.Text) - } - } - - // Not an error reply; let's unmarshal the data - var account Account - if err := json.Unmarshal([]byte(r.Body), &account); err != nil { - return nil, fmt.Errorf("cannot decode API response: %s", err.Error()) - } - return &account, nil -} - -// fileToBase64 is a helper function to convert a file's contents to -// base64-encoded data. Is the data string already contains base64 data, it -// is not modified. -// If contentType is nil, it is detected. -func fileToBase64(data, contentType *string) (*string, error) { - if data == nil { - return nil, nil - } - - if *data == "" { - return data, nil - } - - if strings.Contains(*data, ";base64,") { - return data, nil - } - - // We need to convert the file and file name to base64 - - file, err := os.Open(*data) - if err != nil { - return nil, err - } - defer file.Close() - - fStat, err := file.Stat() - if err != nil { - return nil, err - } - - buffer := make([]byte, fStat.Size()) - _, err = file.Read(buffer) - if err != nil { - return nil, err - } - - var cType string - if contentType == nil || *contentType == "" { - cType = http.DetectContentType(buffer[:512]) - } else { - cType = *contentType - } - contentData := base64.StdEncoding.EncodeToString(buffer) - newData := "data:" + cType + ";base64," + contentData - return &newData, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/api.go b/mastodon/furrybb/vendor/github.com/McKael/madon/api.go deleted file mode 100644 index b232553..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/api.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright 2017 Ollivier Robert -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "bytes" - "encoding/json" - "fmt" - "net/http" - "net/url" - "strings" - - "github.com/sendgrid/rest" -) - -// restAPI actually does the HTTP query -// It is a copy of rest.API with better handling of parameters with multiple values -func restAPI(request rest.Request) (*rest.Response, error) { - c := &rest.Client{HTTPClient: http.DefaultClient} - - // Build the HTTP request object. - if len(request.QueryParams) != 0 { - // Add parameters to the URL - request.BaseURL += "?" - urlp := url.Values{} - for key, value := range request.QueryParams { - // It seems Mastodon doesn't like parameters with index - // numbers, but it needs the brackets. - // Let's check if the key matches '^.+\[.*\]$' - klen := len(key) - if klen == 0 { - continue - } - i := strings.Index(key, "[") - if key[klen-1] == ']' && i > 0 { - // This is an array, let's remove the index number - key = key[:i] + "[]" - } - urlp.Add(key, value) - } - urlpstr := urlp.Encode() - request.BaseURL += urlpstr - } - - req, err := http.NewRequest(string(request.Method), request.BaseURL, bytes.NewBuffer(request.Body)) - if err != nil { - return nil, err - } - - for key, value := range request.Headers { - req.Header.Set(key, value) - } - _, exists := req.Header["Content-Type"] - if len(request.Body) > 0 && !exists { - req.Header.Set("Content-Type", "application/json") - } - - // Build the HTTP client and make the request. - res, err := c.MakeRequest(req) - if err != nil { - return nil, err - } - - // Build Response object. - response, err := rest.BuildResponse(res) - if err != nil { - return nil, err - } - - return response, nil -} - -// prepareRequest inserts all pre-defined stuff -func (mc *Client) prepareRequest(target string, method rest.Method, params apiCallParams) (rest.Request, error) { - var req rest.Request - - if mc == nil { - return req, ErrUninitializedClient - } - - endPoint := mc.APIBase + "/" + target - - // Request headers - hdrs := make(map[string]string) - hdrs["User-Agent"] = fmt.Sprintf("madon/%s", MadonVersion) - if mc.UserToken != nil { - hdrs["Authorization"] = fmt.Sprintf("Bearer %s", mc.UserToken.AccessToken) - } - - req = rest.Request{ - BaseURL: endPoint, - Headers: hdrs, - Method: method, - QueryParams: params, - } - return req, nil -} - -// apiCall makes a call to the Mastodon API server -func (mc *Client) apiCall(endPoint string, method rest.Method, params apiCallParams, data interface{}) error { - if mc == nil { - return fmt.Errorf("use of uninitialized madon client") - } - - // Prepare query - req, err := mc.prepareRequest(endPoint, method, params) - if err != nil { - return err - } - - // Make API call - r, err := restAPI(req) - if err != nil { - return fmt.Errorf("API query (%s) failed: %s", endPoint, err.Error()) - } - - // Check for error reply - var errorResult Error - if err := json.Unmarshal([]byte(r.Body), &errorResult); err == nil { - // The empty object is not an error - if errorResult.Text != "" { - return fmt.Errorf("%s", errorResult.Text) - } - } - - // Not an error reply; let's unmarshal the data - err = json.Unmarshal([]byte(r.Body), &data) - if err != nil { - return fmt.Errorf("cannot decode API response (%s): %s", method, err.Error()) - } - return nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/app.go b/mastodon/furrybb/vendor/github.com/McKael/madon/app.go deleted file mode 100644 index d890224..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/app.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright 2017 Ollivier Robert -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "errors" - "net/url" - "strings" - - "github.com/sendgrid/rest" -) - -type registerApp struct { - ID int `json:"id"` - ClientID string `json:"client_id"` - ClientSecret string `json:"client_secret"` -} - -// buildInstanceURL creates the URL from the instance name or cleans up the -// provided URL -func buildInstanceURL(instanceName string) (string, error) { - if instanceName == "" { - return "", errors.New("no instance provided") - } - - instanceURL := instanceName - if !strings.Contains(instanceURL, "/") { - instanceURL = "https://" + instanceName - } - - u, err := url.ParseRequestURI(instanceURL) - if err != nil { - return "", err - } - - u.Path = "" - u.RawPath = "" - u.RawQuery = "" - u.Fragment = "" - return u.String(), nil -} - -// NewApp registers a new application with a given instance -func NewApp(name string, scopes []string, redirectURI, instanceName string) (mc *Client, err error) { - instanceURL, err := buildInstanceURL(instanceName) - if err != nil { - return nil, err - } - - mc = &Client{ - Name: name, - InstanceURL: instanceURL, - APIBase: instanceURL + currentAPIPath, - } - - params := make(apiCallParams) - params["client_name"] = name - params["scopes"] = strings.Join(scopes, " ") - if redirectURI != "" { - params["redirect_uris"] = redirectURI - } else { - params["redirect_uris"] = NoRedirect - } - - var app registerApp - if err := mc.apiCall("apps", rest.Post, params, &app); err != nil { - return nil, err - } - - mc.ID = app.ClientID - mc.Secret = app.ClientSecret - - return -} - -// RestoreApp recreates an application client with existing secrets -func RestoreApp(name, instanceName, appID, appSecret string, userToken *UserToken) (mc *Client, err error) { - instanceURL, err := buildInstanceURL(instanceName) - if err != nil { - return nil, err - } - - return &Client{ - Name: name, - InstanceURL: instanceURL, - APIBase: instanceURL + currentAPIPath, - ID: appID, - Secret: appSecret, - UserToken: userToken, - }, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/favourites.go b/mastodon/furrybb/vendor/github.com/McKael/madon/favourites.go deleted file mode 100644 index b8f6754..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/favourites.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "github.com/sendgrid/rest" -) - -// GetFavourites returns the list of the user's favourites -func (mc *Client) GetFavourites() ([]Status, error) { - var faves []Status - err := mc.apiCall("favourites", rest.Get, nil, &faves) - if err != nil { - return nil, err - } - return faves, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/instance.go b/mastodon/furrybb/vendor/github.com/McKael/madon/instance.go deleted file mode 100644 index ed5d01b..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/instance.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "github.com/sendgrid/rest" -) - -// GetCurrentInstance returns current instance information -func (mc *Client) GetCurrentInstance() (*Instance, error) { - var i Instance - if err := mc.apiCall("instance", rest.Get, nil, &i); err != nil { - return nil, err - } - return &i, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/login.go b/mastodon/furrybb/vendor/github.com/McKael/madon/login.go deleted file mode 100644 index 1cef1d0..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/login.go +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "encoding/json" - "fmt" - "strings" - - "github.com/sendgrid/rest" -) - -// UserToken represents a user token as returned by the Mastodon API -type UserToken struct { - AccessToken string `json:"access_token"` - CreatedAt int `json:"created_at"` - Scope string `json:"scope"` - TokenType string `json:"token_type"` -} - -// LoginBasic does basic user authentication -func (mc *Client) LoginBasic(username, password string, scopes []string) error { - if mc == nil { - return ErrUninitializedClient - } - - if username == "" { - return fmt.Errorf("missing username") - } - if password == "" { - return fmt.Errorf("missing password") - } - - hdrs := make(map[string]string) - opts := make(map[string]string) - - hdrs["User-Agent"] = "madon/" + MadonVersion - - opts["grant_type"] = "password" - opts["client_id"] = mc.ID - opts["client_secret"] = mc.Secret - opts["username"] = username - opts["password"] = password - if len(scopes) > 0 { - opts["scope"] = strings.Join(scopes, " ") - } - - req := rest.Request{ - BaseURL: mc.InstanceURL + "/oauth/token", - Headers: hdrs, - QueryParams: opts, - Method: rest.Post, - } - - r, err := restAPI(req) - if err != nil { - return err - } - - var resp UserToken - - err = json.Unmarshal([]byte(r.Body), &resp) - if err != nil { - return fmt.Errorf("cannot unmarshal server response: %s", err.Error()) - } - - mc.UserToken = &resp - return nil -} - -// SetUserToken sets an existing user credentials -// No verification of the arguments is made. -func (mc *Client) SetUserToken(token, username, password string, scopes []string) error { - if mc == nil { - return ErrUninitializedClient - } - - mc.UserToken = &UserToken{ - AccessToken: token, - Scope: strings.Join(scopes, " "), - TokenType: "bearer", - } - return nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/madon.go b/mastodon/furrybb/vendor/github.com/McKael/madon/madon.go deleted file mode 100644 index 91109ca..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/madon.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2017 Ollivier Robert -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "errors" -) - -// apiCallParams is a map with the parameters for an API call -type apiCallParams map[string]string - -const ( - // MadonVersion contains the version of the Madon library - MadonVersion = "0.2" - - // API version implemented in this library - apiVersion = "v1" - currentAPIPath = "/api/" + apiVersion - - // NoRedirect is the URI for no redirection in the App registration - NoRedirect = "urn:ietf:wg:oauth:2.0:oob" -) - -// Error codes -var ( - ErrUninitializedClient = errors.New("use of uninitialized madon client") - ErrAlreadyRegistered = errors.New("app already registered") - ErrEntityNotFound = errors.New("entity not found") - ErrInvalidParameter = errors.New("incorrect parameter") - ErrInvalidID = errors.New("incorrect entity ID") -) diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/media.go b/mastodon/furrybb/vendor/github.com/McKael/madon/media.go deleted file mode 100644 index 2a1edc4..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/media.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "mime/multipart" - "os" - "path/filepath" - - "github.com/sendgrid/rest" -) - -// UploadMedia uploads the given file and returns an attachment -func (mc *Client) UploadMedia(filePath string) (*Attachment, error) { - var b bytes.Buffer - - if filePath == "" { - return nil, ErrInvalidParameter - } - - f, err := os.Open(filePath) - if err != nil { - return nil, fmt.Errorf("cannot read file: %s", err.Error()) - } - defer f.Close() - - w := multipart.NewWriter(&b) - formWriter, err := w.CreateFormFile("file", filepath.Base(filePath)) - if err != nil { - return nil, fmt.Errorf("media upload: cannot create form: %s", err.Error()) - } - if _, err = io.Copy(formWriter, f); err != nil { - return nil, fmt.Errorf("media upload: cannot create form: %s", err.Error()) - } - - w.Close() - - req, err := mc.prepareRequest("media", rest.Post, nil) - if err != nil { - return nil, fmt.Errorf("media prepareRequest failed: %s", err.Error()) - } - req.Headers["Content-Type"] = w.FormDataContentType() - req.Body = b.Bytes() - - // Make API call - r, err := restAPI(req) - if err != nil { - return nil, fmt.Errorf("media upload failed: %s", err.Error()) - } - - // Check for error reply - var errorResult Error - if err := json.Unmarshal([]byte(r.Body), &errorResult); err == nil { - // The empty object is not an error - if errorResult.Text != "" { - return nil, fmt.Errorf("%s", errorResult.Text) - } - } - - // Not an error reply; let's unmarshal the data - var attachment Attachment - err = json.Unmarshal([]byte(r.Body), &attachment) - if err != nil { - return nil, fmt.Errorf("cannot decode API response (media): %s", err.Error()) - } - return &attachment, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/notifications.go b/mastodon/furrybb/vendor/github.com/McKael/madon/notifications.go deleted file mode 100644 index ce06c27..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/notifications.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "strconv" - - "github.com/sendgrid/rest" -) - -// GetNotifications returns the list of the user's notifications -func (mc *Client) GetNotifications() ([]Notification, error) { - var notifications []Notification - if err := mc.apiCall("notifications", rest.Get, nil, ¬ifications); err != nil { - return nil, err - } - return notifications, nil -} - -// GetNotification returns a notification -// The returned notification can be nil if there is an error or if the -// requested notification does not exist. -func (mc *Client) GetNotification(notificationID int) (*Notification, error) { - if notificationID < 1 { - return nil, ErrInvalidID - } - - var endPoint = "notifications/" + strconv.Itoa(notificationID) - var notification Notification - if err := mc.apiCall(endPoint, rest.Get, nil, ¬ification); err != nil { - return nil, err - } - if notification.ID == 0 { - return nil, ErrEntityNotFound - } - return ¬ification, nil -} - -// ClearNotifications deletes all notifications from the Mastodon server for -// the authenticated user -func (mc *Client) ClearNotifications() error { - return mc.apiCall("notifications/clear", rest.Post, nil, &Notification{}) -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/report.go b/mastodon/furrybb/vendor/github.com/McKael/madon/report.go deleted file mode 100644 index 2342916..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/report.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "fmt" - "strconv" - - "github.com/sendgrid/rest" -) - -// GetReports returns the current user's reports -func (mc *Client) GetReports() ([]Report, error) { - var reports []Report - if err := mc.apiCall("reports", rest.Get, nil, &reports); err != nil { - return nil, err - } - return reports, nil -} - -// ReportUser reports the user account -func (mc *Client) ReportUser(accountID int, statusIDs []int, comment string) (*Report, error) { - if accountID < 1 || comment == "" || len(statusIDs) < 1 { - return nil, ErrInvalidParameter - } - - params := make(apiCallParams) - params["account_id"] = strconv.Itoa(accountID) - params["comment"] = comment - for i, id := range statusIDs { - if id < 1 { - return nil, ErrInvalidID - } - qID := fmt.Sprintf("status_ids[%d]", i+1) - params[qID] = strconv.Itoa(id) - } - - var report Report - if err := mc.apiCall("reports", rest.Post, params, &report); err != nil { - return nil, err - } - return &report, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/search.go b/mastodon/furrybb/vendor/github.com/McKael/madon/search.go deleted file mode 100644 index b1581e7..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/search.go +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "github.com/sendgrid/rest" -) - -// Search search for contents (accounts or statuses) and returns a Results -func (mc *Client) Search(query string, resolve bool) (*Results, error) { - if query == "" { - return nil, ErrInvalidParameter - } - - params := make(apiCallParams) - params["q"] = query - if resolve { - params["resolve"] = "true" - } - - var results Results - if err := mc.apiCall("search", rest.Get, params, &results); err != nil { - return nil, err - } - return &results, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/status.go b/mastodon/furrybb/vendor/github.com/McKael/madon/status.go deleted file mode 100644 index b2968e0..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/status.go +++ /dev/null @@ -1,229 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "fmt" - "strconv" - - "github.com/sendgrid/rest" -) - -// updateStatusOptions contains option fields for POST and DELETE API calls -type updateStatusOptions struct { - // The ID is used for most commands - ID int - - // The following fields are used for posting a new status - Status string - InReplyToID int - MediaIDs []int - Sensitive bool - SpoilerText string - Visibility string // "direct", "private", "unlisted" or "public" -} - -// queryStatusData queries the statuses API -// The operation 'op' can be empty or "status" (the status itself), "context", -// "card", "reblogged_by", "favourited_by". -// The data argument will receive the object(s) returned by the API server. -func (mc *Client) queryStatusData(statusID int, op string, data interface{}) error { - if statusID < 1 { - return ErrInvalidID - } - - endPoint := "statuses/" + strconv.Itoa(statusID) - - if op != "" && op != "status" { - switch op { - case "context", "card", "reblogged_by", "favourited_by": - default: - return ErrInvalidParameter - } - - endPoint += "/" + op - } - - return mc.apiCall(endPoint, rest.Get, nil, data) -} - -// updateStatusData updates the statuses -// The operation 'op' can be empty or "status" (to post a status), "delete" -// (for deleting a status), "reblog", "unreblog", "favourite", "unfavourite". -// The data argument will receive the object(s) returned by the API server. -func (mc *Client) updateStatusData(op string, opts updateStatusOptions, data interface{}) error { - method := rest.Post - endPoint := "statuses" - params := make(apiCallParams) - - switch op { - case "", "status": - op = "status" - if opts.Status == "" { - return ErrInvalidParameter - } - switch opts.Visibility { - case "", "direct", "private", "unlisted", "public": - // Okay - default: - return ErrInvalidParameter - } - if len(opts.MediaIDs) > 4 { - return fmt.Errorf("too many (>4) media IDs") - } - case "delete": - method = rest.Delete - if opts.ID < 1 { - return ErrInvalidID - } - endPoint += "/" + strconv.Itoa(opts.ID) - case "reblog", "unreblog", "favourite", "unfavourite": - if opts.ID < 1 { - return ErrInvalidID - } - endPoint += "/" + strconv.Itoa(opts.ID) + "/" + op - default: - return ErrInvalidParameter - } - - // Form items for a new toot - if op == "status" { - params["status"] = opts.Status - if opts.InReplyToID > 0 { - params["in_reply_to_id"] = strconv.Itoa(opts.InReplyToID) - } - for i, id := range opts.MediaIDs { - if id < 1 { - return ErrInvalidID - } - qID := fmt.Sprintf("media_ids[%d]", i+1) - params[qID] = strconv.Itoa(id) - } - if opts.Sensitive { - params["sensitive"] = "true" - } - if opts.SpoilerText != "" { - params["spoiler_text"] = opts.SpoilerText - } - if opts.Visibility != "" { - params["visibility"] = opts.Visibility - } - } - - return mc.apiCall(endPoint, method, params, data) -} - -// GetStatus returns a status -// The returned status can be nil if there is an error or if the -// requested ID does not exist. -func (mc *Client) GetStatus(statusID int) (*Status, error) { - var status Status - - if err := mc.queryStatusData(statusID, "status", &status); err != nil { - return nil, err - } - if status.ID == 0 { - return nil, ErrEntityNotFound - } - return &status, nil -} - -// GetStatusContext returns a status context -func (mc *Client) GetStatusContext(statusID int) (*Context, error) { - var context Context - if err := mc.queryStatusData(statusID, "context", &context); err != nil { - return nil, err - } - return &context, nil -} - -// GetStatusCard returns a status card -func (mc *Client) GetStatusCard(statusID int) (*Card, error) { - var card Card - if err := mc.queryStatusData(statusID, "card", &card); err != nil { - return nil, err - } - return &card, nil -} - -// GetStatusRebloggedBy returns a list of the accounts who reblogged a status -func (mc *Client) GetStatusRebloggedBy(statusID int) ([]Account, error) { - var accounts []Account - err := mc.queryStatusData(statusID, "reblogged_by", &accounts) - return accounts, err -} - -// GetStatusFavouritedBy returns a list of the accounts who favourited a status -func (mc *Client) GetStatusFavouritedBy(statusID int) ([]Account, error) { - var accounts []Account - err := mc.queryStatusData(statusID, "favourited_by", &accounts) - return accounts, err -} - -// PostStatus posts a new "toot" -// All parameters but "text" can be empty. -// Visibility must be empty, or one of "direct", "private", "unlisted" and "public". -func (mc *Client) PostStatus(text string, inReplyTo int, mediaIDs []int, sensitive bool, spoilerText string, visibility string) (*Status, error) { - var status Status - o := updateStatusOptions{ - Status: text, - InReplyToID: inReplyTo, - MediaIDs: mediaIDs, - Sensitive: sensitive, - SpoilerText: spoilerText, - Visibility: visibility, - } - - err := mc.updateStatusData("status", o, &status) - if err != nil { - return nil, err - } - if status.ID == 0 { - return nil, ErrEntityNotFound // TODO Change error message - } - return &status, err -} - -// DeleteStatus deletes a status -func (mc *Client) DeleteStatus(statusID int) error { - var status Status - o := updateStatusOptions{ID: statusID} - err := mc.updateStatusData("delete", o, &status) - return err -} - -// ReblogStatus reblogs a status -func (mc *Client) ReblogStatus(statusID int) error { - var status Status - o := updateStatusOptions{ID: statusID} - err := mc.updateStatusData("reblog", o, &status) - return err -} - -// UnreblogStatus unreblogs a status -func (mc *Client) UnreblogStatus(statusID int) error { - var status Status - o := updateStatusOptions{ID: statusID} - err := mc.updateStatusData("unreblog", o, &status) - return err -} - -// FavouriteStatus favourites a status -func (mc *Client) FavouriteStatus(statusID int) error { - var status Status - o := updateStatusOptions{ID: statusID} - err := mc.updateStatusData("favourite", o, &status) - return err -} - -// UnfavouriteStatus unfavourites a status -func (mc *Client) UnfavouriteStatus(statusID int) error { - var status Status - o := updateStatusOptions{ID: statusID} - err := mc.updateStatusData("unfavourite", o, &status) - return err -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/streams.go b/mastodon/furrybb/vendor/github.com/McKael/madon/streams.go deleted file mode 100644 index 9771ff7..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/streams.go +++ /dev/null @@ -1,169 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "encoding/json" - "errors" - "fmt" - "net/url" - "strings" - - "github.com/gorilla/websocket" -) - -// StreamEvent contains a single event from the streaming API -type StreamEvent struct { - Event string // Name of the event (error, update, notification or delete) - Data interface{} // Status, Notification or status ID - Error error // Error message from the StreamListener -} - -// openStream opens a stream URL and returns an http.Response -// Note that the caller should close the connection when it's done reading -// the stream. -// The stream name can be "user", "local", "public" or "hashtag". -// When it is "hashtag", the hashTag argument cannot be empty. -func (mc *Client) openStream(streamName, hashTag string) (*websocket.Conn, error) { - var tag string - - switch streamName { - case "user", "public", "public:local": - case "hashtag": - if hashTag == "" { - return nil, ErrInvalidParameter - } - tag = hashTag - default: - return nil, ErrInvalidParameter - } - - if !strings.HasPrefix(mc.APIBase, "http") { - return nil, errors.New("cannot create Websocket URL: unexpected API base URL") - } - - // Build streaming websocket URL - u, err := url.Parse("ws" + mc.APIBase[4:] + "/streaming/") - if err != nil { - return nil, errors.New("cannot create Websocket URL: " + err.Error()) - } - - urlParams := url.Values{} - urlParams.Add("stream", streamName) - urlParams.Add("access_token", mc.UserToken.AccessToken) - if tag != "" { - urlParams.Add("tag", tag) - } - u.RawQuery = urlParams.Encode() - - c, _, err := websocket.DefaultDialer.Dial(u.String(), nil) - return c, err -} - -// readStream reads from the http.Response and sends events to the events channel -// It stops when the connection is closed or when the stopCh channel is closed. -// The foroutine will close the doneCh channel when it terminates. -func (mc *Client) readStream(events chan<- StreamEvent, stopCh <-chan bool, doneCh chan bool, c *websocket.Conn) { - defer c.Close() - defer close(doneCh) - - go func() { - select { - case <-stopCh: - // Close connection - c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) - case <-doneCh: - // Leave - } - }() - - for { - var msg struct { - Event string - Payload interface{} - } - - err := c.ReadJSON(&msg) - if err != nil { - if strings.Contains(err.Error(), "close 1000 (normal)") { - break // Connection properly closed - } - e := fmt.Errorf("read error: %v", err) - events <- StreamEvent{Event: "error", Error: e} - break - } - - var obj interface{} - - // Decode API object - switch msg.Event { - case "update": - strPayload, ok := msg.Payload.(string) - if !ok { - e := fmt.Errorf("could not decode status: payload isn't a string") - events <- StreamEvent{Event: "error", Error: e} - continue - } - var s Status - if err := json.Unmarshal([]byte(strPayload), &s); err != nil { - e := fmt.Errorf("could not decode status: %v", err) - events <- StreamEvent{Event: "error", Error: e} - continue - } - obj = s - case "notification": - strPayload, ok := msg.Payload.(string) - if !ok { - e := fmt.Errorf("could not decode notification: payload isn't a string") - events <- StreamEvent{Event: "error", Error: e} - continue - } - var notif Notification - if err := json.Unmarshal([]byte(strPayload), ¬if); err != nil { - e := fmt.Errorf("could not decode notification: %v", err) - events <- StreamEvent{Event: "error", Error: e} - continue - } - obj = notif - case "delete": - floatPayload, ok := msg.Payload.(float64) - if !ok { - e := fmt.Errorf("could not decode deletion: payload isn't a number") - events <- StreamEvent{Event: "error", Error: e} - continue - } - obj = int(floatPayload) // statusID - default: - e := fmt.Errorf("unhandled event '%s'", msg.Event) - events <- StreamEvent{Event: "error", Error: e} - continue - } - - // Send event to the channel - events <- StreamEvent{Event: msg.Event, Data: obj} - } -} - -// StreamListener listens to a stream from the Mastodon server -// The stream 'name' can be "user", "local", "public" or "hashtag". -// For 'hashtag', the hashTag argument cannot be empty. -// The events are sent to the events channel (the errors as well). -// The streaming is terminated if the 'stopCh' channel is closed. -// The 'doneCh' channel is closed if the connection is closed by the server. -// Please note that this method launches a goroutine to listen to the events. -func (mc *Client) StreamListener(name, hashTag string, events chan<- StreamEvent, stopCh <-chan bool, doneCh chan bool) error { - if mc == nil { - return ErrUninitializedClient - } - - conn, err := mc.openStream(name, hashTag) - if err != nil { - return err - } - go mc.readStream(events, stopCh, doneCh, conn) - return nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/timelines.go b/mastodon/furrybb/vendor/github.com/McKael/madon/timelines.go deleted file mode 100644 index c3316a0..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/timelines.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "fmt" - "strings" - - "github.com/sendgrid/rest" -) - -// GetTimelines returns a timeline (a list of statuses -// timeline can be "home", "public", or a hashtag (use ":hashtag" or "#hashtag") -// For the public timelines, you can set 'local' to true to get only the -// local instance. -func (mc *Client) GetTimelines(timeline string, local bool) ([]Status, error) { - var endPoint string - - switch { - case timeline == "home", timeline == "public": - endPoint = "timelines/" + timeline - case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"): - hashtag := timeline[1:] - if hashtag == "" { - return nil, fmt.Errorf("timelines API: empty hashtag") - } - endPoint = "timelines/tag/" + hashtag - default: - return nil, fmt.Errorf("GetTimelines: bad timelines argument") - } - - params := make(apiCallParams) - if timeline == "public" && local { - params["local"] = "true" - } - - var tl []Status - if err := mc.apiCall(endPoint, rest.Get, params, &tl); err != nil { - return nil, err - } - return tl, nil -} diff --git a/mastodon/furrybb/vendor/github.com/McKael/madon/types.go b/mastodon/furrybb/vendor/github.com/McKael/madon/types.go deleted file mode 100644 index 767a1ed..0000000 --- a/mastodon/furrybb/vendor/github.com/McKael/madon/types.go +++ /dev/null @@ -1,157 +0,0 @@ -/* -Copyright 2017 Ollivier Robert -Copyright 2017 Mikael Berthe - -Licensed under the MIT license. Please see the LICENSE file is this directory. -*/ - -package madon - -import ( - "time" -) - -// Client contains data for a madon client application -type Client struct { - Name string // Name of the client - ID string // Application ID - Secret string // Application secret - APIBase string // API prefix URL - InstanceURL string // Instance base URL - - UserToken *UserToken // User token -} - -/* -Entities - Everything manipulated/returned by the API -*/ - -// Account represents a Mastodon account entity -type Account struct { - ID int `json:"id"` - Username string `json:"username"` - Acct string `json:"acct"` - DisplayName string `json:"display_name"` - Note string `json:"note"` - URL string `json:"url"` - Avatar string `json:"avatar"` - Header string `json:"header"` - Locked bool `json:"locked"` - CreatedAt time.Time `json:"created_at"` - FollowersCount int `json:"followers_count"` - FollowingCount int `json:"following_count"` - StatusesCount int `json:"statuses_count"` -} - -// Application represents a Mastodon application entity -type Application struct { - Name string `json:"name"` - Website string `json:"website"` -} - -// Attachment represents a Mastodon attachement entity -type Attachment struct { - ID int `json:"iD"` - Type string `json:"type"` - URL string `json:"url"` - RemoteURL string `json:"remote_url"` - PreviewURL string `json:"preview_url"` - TextURL string `json:"text_url"` -} - -// Card represents a Mastodon card entity -type Card struct { - URL string `json:"url"` - Title string `json:"title"` - Description string `json:"description"` - Image string `json:"image"` -} - -// Context represents a Mastodon context entity -type Context struct { - Ancestors []Status `json:"ancestors"` - Descendents []Status `json:"descendents"` -} - -// Error represents a Mastodon error entity -type Error struct { - Text string `json:"error"` -} - -// Instance represents a Mastodon instance entity -type Instance struct { - URI string `json:"uri"` - Title string `json:"title"` - Description string `json:"description"` - Email string `json:"email"` -} - -// Mention represents a Mastodon mention entity -type Mention struct { - ID int `json:"id"` - URL string `json:"url"` - Username string `json:"username"` - Acct string `json:"acct"` -} - -// Notification represents a Mastodon notification entity -type Notification struct { - ID int `json:"id"` - Type string `json:"type"` - CreatedAt time.Time `json:"created_at"` - Account *Account `json:"account"` - Status *Status `json:"status"` -} - -// Relationship represents a Mastodon relationship entity -type Relationship struct { - ID int `json:"id"` - Following bool `json:"following"` - FollowedBy bool `json:"followed_by"` - Blocking bool `json:"blocking"` - Muting bool `json:"muting"` - Requested bool `json:"requested"` -} - -// Report represents a Mastodon report entity -type Report struct { - ID int `json:"iD"` - ActionTaken string `json:"action_taken"` -} - -// Results represents a Mastodon results entity -type Results struct { - Accounts []Account `json:"accounts"` - Statuses []Status `json:"statuses"` - Hashtags []string `json:"hashtags"` -} - -// Status represents a Mastodon status entity -type Status struct { - ID int `json:"id"` - URI string `json:"uri"` - URL string `json:"url"` - Account *Account `json:"account"` - InReplyToID int `json:"in_reply_to_id"` - InReplyToAccountID int `json:"in_reply_to_account_id"` - Reblog *Status `json:"reblog"` - Content string `json:"content"` - CreatedAt time.Time `json:"created_at"` - ReblogsCount int `json:"reblogs_count"` - FavouritesCount int `json:"favourites_count"` - Reblogged bool `json:"reblogged"` - Favourited bool `json:"favourited"` - Sensitive bool `json:"sensitive"` - SpoilerText string `json:"spoiler_text"` - Visibility string `json:"visibility"` - MediaAttachments []Attachment `json:"media_attachments"` - Mentions []Mention `json:"mentions"` - Tags []Tag `json:"tags"` - Application Application `json:"application"` -} - -// Tag represents a Mastodon tag entity -type Tag struct { - Name string `json:"name"` - URL string `json:"url"` -} diff --git a/mastodon/furrybb/vendor/github.com/Xe/gopreload/doc.go b/mastodon/furrybb/vendor/github.com/Xe/gopreload/doc.go deleted file mode 100644 index 720c5c1..0000000 --- a/mastodon/furrybb/vendor/github.com/Xe/gopreload/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Package gopreload is a bit of a hack to emulate the behavior of LD_PRELOAD [ld-preload]. -This allows you to have automatically starting instrumentation, etc. - -[ld-preload]: http://man7.org/linux/man-pages/man8/ld.so.8.html (see LD_PRELOAD section) -*/ -package gopreload diff --git a/mastodon/furrybb/vendor/github.com/Xe/gopreload/preload.go b/mastodon/furrybb/vendor/github.com/Xe/gopreload/preload.go deleted file mode 100644 index 1b5a0c9..0000000 --- a/mastodon/furrybb/vendor/github.com/Xe/gopreload/preload.go +++ /dev/null @@ -1,26 +0,0 @@ -//+build linux,go1.8 - -package gopreload - -import ( - "log" - "os" - "plugin" - "strings" -) - -func init() { - gpv := os.Getenv("GO_PRELOAD") - if gpv == "" { - return - } - - for _, elem := range strings.Split(gpv, ",") { - log.Printf("gopreload: trying to open: %s", elem) - _, err := plugin.Open(elem) - if err != nil { - log.Printf("%v from GO_PRELOAD cannot be loaded: %v", elem, err) - continue - } - } -} diff --git a/mastodon/furrybb/vendor/github.com/Xe/ln/filter.go b/mastodon/furrybb/vendor/github.com/Xe/ln/filter.go deleted file mode 100644 index 586efef..0000000 --- a/mastodon/furrybb/vendor/github.com/Xe/ln/filter.go +++ /dev/null @@ -1,66 +0,0 @@ -package ln - -import ( - "io" - "sync" -) - -// Filter interface for defining chain filters -type Filter interface { - Apply(Event) bool - Run() - Close() -} - -// FilterFunc allows simple functions to implement the Filter interface -type FilterFunc func(e Event) bool - -// Apply implements the Filter interface -func (ff FilterFunc) Apply(e Event) bool { - return ff(e) -} - -// Run implements the Filter interface -func (ff FilterFunc) Run() {} - -// Close implements the Filter interface -func (ff FilterFunc) Close() {} - -// WriterFilter implements a filter, which arbitrarily writes to an io.Writer -type WriterFilter struct { - sync.Mutex - Out io.Writer - Formatter Formatter -} - -// NewWriterFilter creates a filter to add to the chain -func NewWriterFilter(out io.Writer, format Formatter) *WriterFilter { - if format == nil { - format = DefaultFormatter - } - return &WriterFilter{ - Out: out, - Formatter: format, - } -} - -// Apply implements the Filter interface -func (w *WriterFilter) Apply(e Event) bool { - output, err := w.Formatter.Format(e) - if err == nil { - w.Lock() - w.Out.Write(output) - w.Unlock() - } - - return true -} - -// Run implements the Filter interface -func (w *WriterFilter) Run() {} - -// Close implements the Filter interface -func (w *WriterFilter) Close() {} - -// NilFilter is safe to return as a Filter, but does nothing -var NilFilter = FilterFunc(func(e Event) bool { return true }) diff --git a/mastodon/furrybb/vendor/github.com/Xe/ln/formatter.go b/mastodon/furrybb/vendor/github.com/Xe/ln/formatter.go deleted file mode 100644 index ecd4743..0000000 --- a/mastodon/furrybb/vendor/github.com/Xe/ln/formatter.go +++ /dev/null @@ -1,110 +0,0 @@ -package ln - -import ( - "bytes" - "fmt" - "time" -) - -var ( - // DefaultTimeFormat represents the way in which time will be formatted by default - DefaultTimeFormat = time.RFC3339 -) - -// Formatter defines the formatting of events -type Formatter interface { - Format(Event) ([]byte, error) -} - -// DefaultFormatter is the default way in which to format events -var DefaultFormatter Formatter - -func init() { - DefaultFormatter = NewTextFormatter() -} - -// TextFormatter formats events as key value pairs. -// Any remaining text not wrapped in an instance of `F` will be -// placed at the end. -type TextFormatter struct { - TimeFormat string -} - -// NewTextFormatter returns a Formatter that outputs as text. -func NewTextFormatter() Formatter { - return &TextFormatter{TimeFormat: DefaultTimeFormat} -} - -// Format implements the Formatter interface -func (t *TextFormatter) Format(e Event) ([]byte, error) { - var writer bytes.Buffer - - writer.WriteString("time=\"") - writer.WriteString(e.Time.Format(t.TimeFormat)) - writer.WriteString("\"") - - keys := make([]string, len(e.Data)) - i := 0 - - for k := range e.Data { - keys[i] = k - i++ - } - - for _, k := range keys { - v := e.Data[k] - - writer.WriteByte(' ') - if shouldQuote(k) { - writer.WriteString(fmt.Sprintf("%q", k)) - } else { - writer.WriteString(k) - } - - writer.WriteByte('=') - - switch v.(type) { - case string: - vs, _ := v.(string) - if shouldQuote(vs) { - fmt.Fprintf(&writer, "%q", vs) - } else { - writer.WriteString(vs) - } - case error: - tmperr, _ := v.(error) - es := tmperr.Error() - - if shouldQuote(es) { - fmt.Fprintf(&writer, "%q", es) - } else { - writer.WriteString(es) - } - case time.Time: - tmptime, _ := v.(time.Time) - writer.WriteString(tmptime.Format(time.RFC3339)) - default: - fmt.Fprint(&writer, v) - } - } - - if len(e.Message) > 0 { - fmt.Fprintf(&writer, " _msg=%q", e.Message) - } - - writer.WriteByte('\n') - return writer.Bytes(), nil -} - -func shouldQuote(s string) bool { - for _, b := range s { - if !((b >= 'A' && b <= 'Z') || - (b >= 'a' && b <= 'z') || - (b >= '0' && b <= '9') || - (b == '-' || b == '.' || b == '#' || - b == '/' || b == '_')) { - return true - } - } - return false -} diff --git a/mastodon/furrybb/vendor/github.com/Xe/ln/logger.go b/mastodon/furrybb/vendor/github.com/Xe/ln/logger.go deleted file mode 100644 index cdfe89e..0000000 --- a/mastodon/furrybb/vendor/github.com/Xe/ln/logger.go +++ /dev/null @@ -1,141 +0,0 @@ -package ln - -import ( - "fmt" - "os" - "time" - - "github.com/pkg/errors" -) - -// Logger holds the current priority and list of filters -type Logger struct { - Filters []Filter -} - -// DefaultLogger is the default implementation of Logger -var DefaultLogger *Logger - -func init() { - var defaultFilters []Filter - - // Default to STDOUT for logging, but allow LN_OUT to change it. - out := os.Stdout - if os.Getenv("LN_OUT") == "" { - out = os.Stderr - } - - defaultFilters = append(defaultFilters, NewWriterFilter(out, nil)) - - DefaultLogger = &Logger{ - Filters: defaultFilters, - } - -} - -// F is a key-value mapping for structured data. -type F map[string]interface{} - -type Fer interface { - F() map[string]interface{} -} - -// Event represents an event -type Event struct { - Time time.Time - Data F - Message string -} - -// Log is the generic logging method. -func (l *Logger) Log(xs ...interface{}) { - var bits []interface{} - event := Event{Time: time.Now()} - - addF := func(bf F) { - if event.Data == nil { - event.Data = bf - } else { - for k, v := range bf { - event.Data[k] = v - } - } - } - - // Assemble the event - for _, b := range xs { - if bf, ok := b.(F); ok { - addF(bf) - } else if fer, ok := b.(Fer); ok { - addF(F(fer.F())) - } else { - bits = append(bits, b) - } - } - - event.Message = fmt.Sprint(bits...) - - if os.Getenv("LN_DEBUG_ALL_EVENTS") == "1" { - frame := callersFrame() - if event.Data == nil { - event.Data = make(F) - } - event.Data["_lineno"] = frame.lineno - event.Data["_function"] = frame.function - event.Data["_filename"] = frame.filename - } - - l.filter(event) -} - -func (l *Logger) filter(e Event) { - for _, f := range l.Filters { - if !f.Apply(e) { - return - } - } -} - -// Error logs an error and information about the context of said error. -func (l *Logger) Error(err error, xs ...interface{}) { - data := F{} - frame := callersFrame() - - data["_lineno"] = frame.lineno - data["_function"] = frame.function - data["_filename"] = frame.filename - data["err"] = err - - cause := errors.Cause(err) - if cause != nil { - data["cause"] = cause.Error() - } - - xs = append(xs, data) - - l.Log(xs...) -} - -// Fatal logs this set of values, then exits with status code 1. -func (l *Logger) Fatal(xs ...interface{}) { - l.Log(xs...) - - os.Exit(1) -} - -// Default Implementation - -// Log is the generic logging method. -func Log(xs ...interface{}) { - DefaultLogger.Log(xs...) -} - -// Error logs an error and information about the context of said error. -func Error(err error, xs ...interface{}) { - DefaultLogger.Error(err, xs...) -} - -// Fatal logs this set of values, then exits with status code 1. -func Fatal(xs ...interface{}) { - DefaultLogger.Fatal(xs...) -} diff --git a/mastodon/furrybb/vendor/github.com/Xe/ln/stack.go b/mastodon/furrybb/vendor/github.com/Xe/ln/stack.go deleted file mode 100644 index 1cf1e7a..0000000 --- a/mastodon/furrybb/vendor/github.com/Xe/ln/stack.go +++ /dev/null @@ -1,44 +0,0 @@ -package ln - -import ( - "os" - "runtime" - "strings" -) - -type frame struct { - filename string - function string - lineno int -} - -// skips 2 frames, since Caller returns the current frame, and we need -// the caller's caller. -func callersFrame() frame { - var out frame - pc, file, line, ok := runtime.Caller(3) - if !ok { - return out - } - srcLoc := strings.LastIndex(file, "/src/") - if srcLoc >= 0 { - file = file[srcLoc+5:] - } - out.filename = file - out.function = functionName(pc) - out.lineno = line - - return out -} - -func functionName(pc uintptr) string { - fn := runtime.FuncForPC(pc) - if fn == nil { - return "???" - } - name := fn.Name() - beg := strings.LastIndex(name, string(os.PathSeparator)) - return name[beg+1:] - // end := strings.LastIndex(name, string(os.PathSeparator)) - // return name[end+1 : len(name)] -} diff --git a/mastodon/furrybb/vendor/github.com/caarlos0/env/env.go b/mastodon/furrybb/vendor/github.com/caarlos0/env/env.go deleted file mode 100644 index 25e5117..0000000 --- a/mastodon/furrybb/vendor/github.com/caarlos0/env/env.go +++ /dev/null @@ -1,275 +0,0 @@ -package env - -import ( - "errors" - "os" - "reflect" - "strconv" - "strings" - "time" -) - -var ( - // ErrNotAStructPtr is returned if you pass something that is not a pointer to a - // Struct to Parse - ErrNotAStructPtr = errors.New("Expected a pointer to a Struct") - // ErrUnsupportedType if the struct field type is not supported by env - ErrUnsupportedType = errors.New("Type is not supported") - // ErrUnsupportedSliceType if the slice element type is not supported by env - ErrUnsupportedSliceType = errors.New("Unsupported slice type") - // Friendly names for reflect types - sliceOfInts = reflect.TypeOf([]int(nil)) - sliceOfInt64s = reflect.TypeOf([]int64