fix golangcilint issues

This commit is contained in:
Karmanyaah Malhotra 2021-03-05 00:47:47 -05:00
parent b6715c2375
commit 042fb9a951
2 changed files with 10 additions and 17 deletions

View File

@ -3,6 +3,7 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"log"
"os" "os"
"github.com/densestvoid/groupme" "github.com/densestvoid/groupme"
@ -49,10 +50,16 @@ func main() {
client = groupme.NewClient(authorizationToken) client = groupme.NewClient(authorizationToken)
User, _ := client.MyUser(context.Background()) User, _ := client.MyUser(context.Background())
p.SubscribeToUser(context.Background(), User.ID, authorizationToken) err = p.SubscribeToUser(context.Background(), User.ID, authorizationToken)
if err != nil {
log.Fatal(err)
}
for _, j := range groups { for _, j := range groups {
p.SubscribeToGroup(context.TODO(), j.ID, authorizationToken) err = p.SubscribeToGroup(context.TODO(), j.ID, authorizationToken)
if err != nil {
log.Fatal(err)
}
} }
p.AddFullHandler(Handler{User: User}) p.AddFullHandler(Handler{User: User})

View File

@ -19,8 +19,6 @@ const (
userChannel = "/user/" userChannel = "/user/"
groupChannel = "/group/" groupChannel = "/group/"
dmChannel = "/direct_message/" dmChannel = "/direct_message/"
handshakeChannel = "/meta/handshake"
connectChannel = "/meta/connect"
subscribeChannel = "/meta/subscribe" subscribeChannel = "/meta/subscribe"
) )
@ -131,7 +129,7 @@ func (r *PushSubscription) StartListening(context context.Context) {
for msg := range r.channel { for msg := range r.channel {
r.LastConnected = time.Now().Unix() r.LastConnected = time.Now().Unix()
data := msg.Data() data := msg.Data()
content, _ := data["subject"] content := data["subject"] //TODO ok
contentType := data["type"].(string) contentType := data["type"].(string)
channel := msg.Channel() channel := msg.Channel()
@ -165,7 +163,6 @@ func (r *PushSubscription) StartListening(context context.Context) {
} }
} }
break
case "like.create": case "like.create":
//should be an associated chatEvent //should be an associated chatEvent
break break
@ -179,7 +176,6 @@ func (r *PushSubscription) StartListening(context context.Context) {
} }
} }
break
case "ping": case "ping":
break break
default: //TODO: see if any other types are returned default: //TODO: see if any other types are returned
@ -206,7 +202,6 @@ func (r *PushSubscription) chatEvent(contentType string, b []byte) {
h.HandleLike(data.ID, data.FavoritedBy) h.HandleLike(data.ID, data.FavoritedBy)
} }
} }
break
default: //TODO: see if any other types are returned default: //TODO: see if any other types are returned
log.Println(contentType) log.Println(contentType)
log.Fatalln(string(b)) log.Fatalln(string(b))
@ -232,7 +227,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleNewNickname(groupID, ID(strconv.Itoa(data.User.ID)), data.Name) h.HandleNewNickname(groupID, ID(strconv.Itoa(data.User.ID)), data.Name)
} }
} }
break
case "membership.avatar_changed": case "membership.avatar_changed":
data := struct { data := struct {
AvatarURL string `json:"avatar_url"` AvatarURL string `json:"avatar_url"`
@ -247,7 +241,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleNewAvatarInGroup(groupID, ID(strconv.Itoa(data.User.ID)), data.AvatarURL) h.HandleNewAvatarInGroup(groupID, ID(strconv.Itoa(data.User.ID)), data.AvatarURL)
} }
} }
break
case "membership.announce.added": case "membership.announce.added":
data := struct { data := struct {
Added []Member `json:"added_users"` Added []Member `json:"added_users"`
@ -258,7 +251,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleMembers(groupID, data.Added, true) h.HandleMembers(groupID, data.Added, true)
} }
} }
break
case "membership.notifications.removed": case "membership.notifications.removed":
data := struct { data := struct {
Added Member `json:"removed_user"` Added Member `json:"removed_user"`
@ -269,7 +261,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleMembers(groupID, []Member{data.Added}, false) h.HandleMembers(groupID, []Member{data.Added}, false)
} }
} }
break
case "group.role_change_admin": case "group.role_change_admin":
//TODO //TODO
break break
@ -284,7 +275,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleGroupName(groupID, data.Name) h.HandleGroupName(groupID, data.Name)
} }
} }
break
case "group.topic_change": case "group.topic_change":
data := struct { data := struct {
Topic string Topic string
@ -296,7 +286,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleGroupTopic(groupID, data.Topic) h.HandleGroupTopic(groupID, data.Topic)
} }
} }
break
case "group.avatar_change": case "group.avatar_change":
data := struct { data := struct {
AvatarURL string `json:"avatar_url"` AvatarURL string `json:"avatar_url"`
@ -308,7 +297,6 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleGroupAvatar(groupID, data.AvatarURL) h.HandleGroupAvatar(groupID, data.AvatarURL)
} }
} }
break
case "group.like_icon_set": case "group.like_icon_set":
data := struct { data := struct {
LikeIcon struct { LikeIcon struct {
@ -324,14 +312,12 @@ func (r *PushSubscription) systemEvent(groupID ID, msg systemMessage) {
h.HandleLikeIcon(groupID, data.LikeIcon.PackID, data.LikeIcon.PackIndex, data.LikeIcon.Type) h.HandleLikeIcon(groupID, data.LikeIcon.PackID, data.LikeIcon.PackIndex, data.LikeIcon.Type)
} }
} }
break
case "group.like_icon_removed": case "group.like_icon_removed":
for _, h := range r.handlers { for _, h := range r.handlers {
if h, ok := h.(HandleGroupMetadata); ok { if h, ok := h.(HandleGroupMetadata); ok {
h.HandleLikeIcon(groupID, 0, 0, "") h.HandleLikeIcon(groupID, 0, 0, "")
} }
} }
break
case "group.type_change", "group.required_approval_enabled", "group.required_approval_disabled": case "group.type_change", "group.required_approval_enabled", "group.required_approval_disabled":
//TODO: group joining //TODO: group joining
break break