Add 2 methods: fetch all threads, fetch all users involved in threads#300
Conversation
Add a method to get all threads in Location (INBOX, ARCHIVED...)
Use "self" instead of "client"
Add a method to get all users involved in threads (given as a parameter)
madsmtm
left a comment
There was a problem hiding this comment.
Thanks for you submission! I like your fetchThreads implementation, it's a nice abstraction, but perhaps it would be nice to have a limit parameter, so that you don't fetch a lot of threads you really don't need?
Yes, BTW an |
madsmtm
left a comment
There was a problem hiding this comment.
I was thinking, merging fetchThreadList into fetchThreads altogether (or the other way around?) could be a cool solution.
That is, make is such that we have parameters before, after and limit (and maybe offset?), and then we'd able to combine these in any way we like.
For example, after=1514761200 and before=1519858800 would fetch threads from the start of January to start of March. Then you could add a limit=3, in case you only needed three threads.
Also, you could implement after and before as datetime objects, see #278
|
Totally forgot about this PR! 👎 |
|
I'd say it's still relevant, |
|
And besides, there's nothing preventing us from using part of the implementation from here in the new API |
|
Done, testing needed :) By the way is it possible to know last modification date of some threads present in the test accounts? |
| if before is not None or after is not None: | ||
| for t in list(threads): | ||
| last_message_timestamp = int(t.last_message_timestamp) | ||
| if (before is not None and last_message_timestamp > before) or \ |
There was a problem hiding this comment.
It seems kinda unclean that this is duplicated further up, is there a way we can refactor, and merge these?
|
You're right about not using datetime objects yet, at least that'll give some sort of consistency ;) But no, I can't think of a way to properly test these methods |
|
I went ahead and did some of the changes I requested, since this PR would have gotten lost otherwise (and I really wanted this functionality 😁). Thanks for your work! 🎉 |
As fetchAllUsers() seems broken (#282 ), I added two methods:
Example: to fetch all users in INBOX simply use:
Users = client.fetchAllUsersFromThreads(client.fetchThreads(ThreadLocation.INBOX))
fetchAllUsersFromThreads() might be long to finish, should progress be printed? (based on the number of threads given as parameter)