1
0
mirror of synced 2024-11-25 06:16:07 +03:00

Merge pull request #63 from jBugman/cleanup

Fixed staticcheck warnings
This commit is contained in:
Harrison Shoebridge 2019-07-26 08:50:48 +10:00 committed by GitHub
commit b90fe59765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 19 deletions

View File

@ -17,7 +17,6 @@ import (
const (
webhooksPath = "/webhooks"
loginPath = "/signin"
logoutPath = "/signout"
validUsername = "john"
validPassword = "secret"

6
go.sum Normal file
View File

@ -0,0 +1,6 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

View File

@ -19,7 +19,7 @@ const (
// SendSettingsURL is API endpoint for saving settings.
SendSettingsURL = "https://graph.facebook.com/v2.6/me/thread_settings"
// MessengerProfileURL is the API endoint where yout bot set properties that define various aspects of the following Messenger Platform features.
// MessengerProfileURL is the API endpoint where you set properties that define various aspects of the following Messenger Platform features.
// Used in the form https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
// https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api/
MessengerProfileURL = "https://graph.facebook.com/v2.6/me/messenger_profile"
@ -192,7 +192,7 @@ func (m *Messenger) ProfileByID(id int64, profileFields []string) (Profile, erro
qr := QueryResponse{}
err = json.Unmarshal(content, &qr)
if qr.Error != nil {
err = fmt.Errorf("Facebook error : %s", qr.Error.Message)
err = fmt.Errorf("facebook error: %s", qr.Error.Message)
}
}
@ -341,7 +341,7 @@ func (m *Messenger) checkIntegrity(r *http.Request) error {
func (m *Messenger) dispatch(r Receive) {
for _, entry := range r.Entry {
for _, info := range entry.Messaging {
a := m.classify(info, entry)
a := m.classify(info)
if a == UnknownAction {
fmt.Println("Unknown action:", info)
continue
@ -478,7 +478,7 @@ func (m *Messenger) EnableChatExtension(homeURL HomeURL) error {
}
// classify determines what type of message a webhook event is.
func (m *Messenger) classify(info MessageInfo, e Entry) Action {
func (m *Messenger) classify(info MessageInfo) Action {
if info.Message != nil {
return TextAction
} else if info.Delivery != nil {

View File

@ -56,7 +56,7 @@ func TestMessenger_Classify(t *testing.T) {
},
} {
t.Run("action "+name, func(t *testing.T) {
action := m.classify(test.msgInfo, Entry{})
action := m.classify(test.msgInfo)
assert.Exactly(t, action, test.expected)
})
}

View File

@ -1,17 +1,5 @@
package messenger
import "encoding/json"
func unmarshalPassThreadControl(data []byte) (passThreadControl, error) {
var r passThreadControl
err := json.Unmarshal(data, &r)
return r, err
}
func (r *passThreadControl) marshal() ([]byte, error) {
return json.Marshal(r)
}
type passThreadControl struct {
Recipient Recipient `json:"recipient"`
TargetAppID int64 `json:"target_app_id"`

View File

@ -77,8 +77,11 @@ func checkFacebookError(r io.Reader) error {
qr := QueryResponse{}
err = json.NewDecoder(r).Decode(&qr)
if err != nil {
return fmt.Errorf("json unmarshal error: %s", err)
}
if qr.Error != nil {
err = fmt.Errorf("Facebook error : %s", qr.Error.Message)
err = fmt.Errorf("facebook error: %s", qr.Error.Message)
return err
}