equal
deleted
inserted
replaced
67 |
67 |
68 // getMultipleAccounts returns a list of account entities |
68 // getMultipleAccounts returns a list of account entities |
69 // The operation 'op' can be "followers", "following", "search", "blocks", |
69 // The operation 'op' can be "followers", "following", "search", "blocks", |
70 // "mutes", "follow_requests". |
70 // "mutes", "follow_requests". |
71 // The id is optional and depends on the operation. |
71 // The id is optional and depends on the operation. |
|
72 // If opts.All is true, several requests will be made until the API server |
|
73 // has nothing to return. |
72 func (mc *Client) getMultipleAccounts(op string, opts *getAccountsOptions) ([]Account, error) { |
74 func (mc *Client) getMultipleAccounts(op string, opts *getAccountsOptions) ([]Account, error) { |
73 var endPoint string |
75 var endPoint string |
74 var lopt *LimitParams |
76 var lopt *LimitParams |
75 |
77 |
76 if opts != nil { |
78 if opts != nil { |
110 if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &accounts); err != nil { |
112 if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &accounts); err != nil { |
111 return nil, err |
113 return nil, err |
112 } |
114 } |
113 if lopt != nil { // Fetch more pages to reach our limit |
115 if lopt != nil { // Fetch more pages to reach our limit |
114 var accountSlice []Account |
116 var accountSlice []Account |
115 for lopt.Limit > len(accounts) && links.next != nil { |
117 for (lopt.All || lopt.Limit > len(accounts)) && links.next != nil { |
116 newlopt := links.next |
118 newlopt := links.next |
117 links = apiLinks{} |
119 links = apiLinks{} |
118 if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &accountSlice); err != nil { |
120 if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &accountSlice); err != nil { |
119 return nil, err |
121 return nil, err |
120 } |
122 } |
306 } |
308 } |
307 |
309 |
308 // GetAccountStatuses returns a list of status entities for the given account |
310 // GetAccountStatuses returns a list of status entities for the given account |
309 // If onlyMedia is true, returns only statuses that have media attachments. |
311 // If onlyMedia is true, returns only statuses that have media attachments. |
310 // If excludeReplies is true, skip statuses that reply to other statuses. |
312 // If excludeReplies is true, skip statuses that reply to other statuses. |
|
313 // If lopt.All is true, several requests will be made until the API server |
|
314 // has nothing to return. |
|
315 // If lopt.Limit is set (and not All), several queries can be made until the |
|
316 // limit is reached. |
311 func (mc *Client) GetAccountStatuses(accountID int, onlyMedia, excludeReplies bool, lopt *LimitParams) ([]Status, error) { |
317 func (mc *Client) GetAccountStatuses(accountID int, onlyMedia, excludeReplies bool, lopt *LimitParams) ([]Status, error) { |
312 if accountID < 1 { |
318 if accountID < 1 { |
313 return nil, ErrInvalidID |
319 return nil, ErrInvalidID |
314 } |
320 } |
315 |
321 |
327 if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &sl); err != nil { |
333 if err := mc.apiCall(endPoint, rest.Get, params, lopt, &links, &sl); err != nil { |
328 return nil, err |
334 return nil, err |
329 } |
335 } |
330 if lopt != nil { // Fetch more pages to reach our limit |
336 if lopt != nil { // Fetch more pages to reach our limit |
331 var statusSlice []Status |
337 var statusSlice []Status |
332 for lopt.Limit > len(sl) && links.next != nil { |
338 for (lopt.All || lopt.Limit > len(sl)) && links.next != nil { |
333 newlopt := links.next |
339 newlopt := links.next |
334 links = apiLinks{} |
340 links = apiLinks{} |
335 if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil { |
341 if err := mc.apiCall(endPoint, rest.Get, params, newlopt, &links, &statusSlice); err != nil { |
336 return nil, err |
342 return nil, err |
337 } |
343 } |