GetTimelines & StreamListener: Accept "direct" timeline
authorMikael Berthe <mikael@lilotux.net>
Fri, 07 Sep 2018 21:49:44 +0200
changeset 244 4508376c8fcb
parent 243 7386c6a454a8
child 245 304b518cabbf
GetTimelines & StreamListener: Accept "direct" timeline
streams.go
timelines.go
--- a/streams.go	Fri Sep 07 19:17:12 2018 +0200
+++ b/streams.go	Fri Sep 07 21:49:44 2018 +0200
@@ -25,14 +25,15 @@
 // 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", "list" or "hashtag".
+// The stream name can be "user", "local", "public", "direct", "list" or
+// "hashtag".
 // When it is "hashtag", the param argument contains the hashtag.
 // When it is "list", the param argument contains the list ID.
 func (mc *Client) openStream(streamName, param string) (*websocket.Conn, error) {
 	var tag, list string
 
 	switch streamName {
-	case "user", "public", "public:local":
+	case "user", "public", "public:local", "direct":
 	case "hashtag":
 		if param == "" {
 			return nil, ErrInvalidParameter
--- a/timelines.go	Fri Sep 07 19:17:12 2018 +0200
+++ b/timelines.go	Fri Sep 07 21:49:44 2018 +0200
@@ -12,9 +12,9 @@
 	"github.com/pkg/errors"
 )
 
-// GetTimelines returns a timeline (a list of statuses
-// timeline can be "home", "public", a hashtag (use ":hashtag" or "#hashtag")
-// or a list (use "!N", e.g. "!42" for list ID #42).
+// GetTimelines returns a timeline (a list of statuses)
+// timeline can be "home", "public", "direct", a hashtag (use ":hashtag" or
+// "#hashtag") or a list (use "!N", e.g. "!42" for list ID #42).
 // For the public timelines, you can set 'local' to true to get only the
 // local instance.
 // Set 'onlyMedia' to true to only get statuses that have media attachments.
@@ -26,7 +26,7 @@
 	var endPoint string
 
 	switch {
-	case timeline == "home", timeline == "public":
+	case timeline == "home", timeline == "public", timeline == "direct":
 		endPoint = "timelines/" + timeline
 	case strings.HasPrefix(timeline, ":"), strings.HasPrefix(timeline, "#"):
 		hashtag := timeline[1:]