GetTimelines: Add parameter 'onlyMedia' (Mastodon 2.3.0+)
authorMikael Berthe <mikael@lilotux.net>
Tue, 20 Mar 2018 19:20:31 +0100
changeset 214 642d690de0ba
parent 213 3cade8971ed9
child 215 40ed4e2db3b9
GetTimelines: Add parameter 'onlyMedia' (Mastodon 2.3.0+)
timelines.go
--- a/timelines.go	Tue Mar 20 18:55:00 2018 +0100
+++ b/timelines.go	Tue Mar 20 19:20:31 2018 +0100
@@ -17,11 +17,12 @@
 // 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.
 // If lopt.All is true, several requests will be made until the API server
 // has nothing to return.
 // If lopt.Limit is set (and not All), several queries can be made until the
 // limit is reached.
-func (mc *Client) GetTimelines(timeline string, local bool, lopt *LimitParams) ([]Status, error) {
+func (mc *Client) GetTimelines(timeline string, local, onlyMedia bool, lopt *LimitParams) ([]Status, error) {
 	var endPoint string
 
 	switch {
@@ -49,6 +50,9 @@
 	if timeline == "public" && local {
 		params["local"] = "true"
 	}
+	if onlyMedia {
+		params["only_media"] = "true"
+	}
 
 	return mc.getMultipleStatuses(endPoint, params, lopt)
 }