Improve logging on client calls

This commit is contained in:
Peter Stuifzand 2018-05-13 19:38:46 +02:00
parent 28e5f4d7be
commit da53190a97
2 changed files with 15 additions and 0 deletions

View File

@ -180,9 +180,14 @@ func (b *memoryBackend) ChannelsUpdate(uid, name string) microsub.Channel {
// ChannelsDelete deletes a channel // ChannelsDelete deletes a channel
func (b *memoryBackend) ChannelsDelete(uid string) { func (b *memoryBackend) ChannelsDelete(uid string) {
defer b.save() defer b.save()
if _, e := b.Channels[uid]; e { if _, e := b.Channels[uid]; e {
delete(b.Channels, uid) delete(b.Channels, uid)
} }
if _, e := b.Feeds[uid]; e {
delete(b.Feeds, uid)
}
} }
func mapToAuthor(result map[string]string) *microsub.Card { func mapToAuthor(result map[string]string) *microsub.Card {

View File

@ -62,6 +62,7 @@ func (c *Client) ChannelsGetList() []microsub.Channel {
args := make(map[string]string) args := make(map[string]string)
res, err := c.microsubGetRequest("channels", args) res, err := c.microsubGetRequest("channels", args)
if err != nil { if err != nil {
log.Println(err)
return []microsub.Channel{} return []microsub.Channel{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -83,6 +84,7 @@ func (c *Client) TimelineGet(before, after, channel string) microsub.Timeline {
args["channel"] = channel args["channel"] = channel
res, err := c.microsubGetRequest("timeline", args) res, err := c.microsubGetRequest("timeline", args)
if err != nil { if err != nil {
log.Println(err)
return microsub.Timeline{} return microsub.Timeline{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -100,6 +102,7 @@ func (c *Client) PreviewURL(url string) microsub.Timeline {
args["url"] = url args["url"] = url
res, err := c.microsubGetRequest("preview", args) res, err := c.microsubGetRequest("preview", args)
if err != nil { if err != nil {
log.Println(err)
return microsub.Timeline{} return microsub.Timeline{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -114,6 +117,7 @@ func (c *Client) FollowGetList(channel string) []microsub.Feed {
args["channel"] = channel args["channel"] = channel
res, err := c.microsubGetRequest("follow", args) res, err := c.microsubGetRequest("follow", args)
if err != nil { if err != nil {
log.Println(err)
return []microsub.Feed{} return []microsub.Feed{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -131,6 +135,7 @@ func (c *Client) ChannelsCreate(name string) microsub.Channel {
args["name"] = name args["name"] = name
res, err := c.microsubPostRequest("channels", args) res, err := c.microsubPostRequest("channels", args)
if err != nil { if err != nil {
log.Println(err)
return microsub.Channel{} return microsub.Channel{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -146,6 +151,7 @@ func (c *Client) ChannelsUpdate(uid, name string) microsub.Channel {
args["uid"] = uid args["uid"] = uid
res, err := c.microsubPostRequest("channels", args) res, err := c.microsubPostRequest("channels", args)
if err != nil { if err != nil {
log.Println(err)
return microsub.Channel{} return microsub.Channel{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -161,6 +167,7 @@ func (c *Client) ChannelsDelete(uid string) {
args["method"] = "delete" args["method"] = "delete"
res, err := c.microsubPostRequest("channels", args) res, err := c.microsubPostRequest("channels", args)
if err != nil { if err != nil {
log.Println(err)
return return
} }
res.Body.Close() res.Body.Close()
@ -172,6 +179,7 @@ func (c *Client) FollowURL(channel, url string) microsub.Feed {
args["url"] = url args["url"] = url
res, err := c.microsubPostRequest("follow", args) res, err := c.microsubPostRequest("follow", args)
if err != nil { if err != nil {
log.Println(err)
return microsub.Feed{} return microsub.Feed{}
} }
defer res.Body.Close() defer res.Body.Close()
@ -187,6 +195,7 @@ func (c *Client) UnfollowURL(channel, url string) {
args["url"] = url args["url"] = url
res, err := c.microsubPostRequest("unfollow", args) res, err := c.microsubPostRequest("unfollow", args)
if err != nil { if err != nil {
log.Println(err)
return return
} }
res.Body.Close() res.Body.Close()
@ -197,6 +206,7 @@ func (c *Client) Search(query string) []microsub.Feed {
args["query"] = query args["query"] = query
res, err := c.microsubPostRequest("search", args) res, err := c.microsubPostRequest("search", args)
if err != nil { if err != nil {
log.Println(err)
return []microsub.Feed{} return []microsub.Feed{}
} }
type searchResponse struct { type searchResponse struct {