-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add muted/blocked users api #180
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||||||||||||
from typing import TYPE_CHECKING | ||||||||||||||||
|
||||||||||||||||
from ..constants import ( | ||||||||||||||||
BLOCKED_ACCOUNTS_ALL_FEATURES, | ||||||||||||||||
BOOKMARK_FOLDER_TIMELINE_FEATURES, | ||||||||||||||||
COMMUNITY_NOTE_FEATURES, | ||||||||||||||||
COMMUNITY_TWEETS_FEATURES, | ||||||||||||||||
|
@@ -96,6 +97,8 @@ def url(path): | |||||||||||||||
MEMBERS_SLICE_TIMELINE_QUERY = url('KDAssJ5lafCy-asH4wm1dw/membersSliceTimeline_Query') | ||||||||||||||||
MODERATORS_SLICE_TIMELINE_QUERY = url('9KI_r8e-tgp3--N5SZYVjg/moderatorsSliceTimeline_Query') | ||||||||||||||||
COMMUNITY_TWEET_SEARCH_MODULE_QUERY = url('5341rmzzvdjqfmPKfoHUBw/CommunityTweetSearchModuleQuery') | ||||||||||||||||
BLOCKED_ACCOUNTS_ALL = url("ugCclQ08T0qMYjS3SYvMdQ/BlockedAccountsAll") | ||||||||||||||||
MUTED_ACCOUNTS = url("J0tjDZrm9M6UYRoPtXcvhg/MutedAccounts") | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
class GQLClient: | ||||||||||||||||
|
@@ -690,3 +693,25 @@ async def tweet_result_by_rest_id(self, tweet_id): | |||||||||||||||
return await self.gql_get( | ||||||||||||||||
Endpoint.TWEET_RESULT_BY_REST_ID, variables, TWEET_RESULT_BY_REST_ID_FEATURES, extra_params=params | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
async def blocked_accounts_all(self, user_id, count, cursor): | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Standardize coding style across similar methods The blocked_accounts_all and muted_accounts methods are quite similar, but use slightly different styles for defining the variables dictionary. Consider standardizing the coding style across these methods for better consistency and readability.
Suggested change
|
||||||||||||||||
variables = { | ||||||||||||||||
"count": count, | ||||||||||||||||
"includePromotedContent": False, | ||||||||||||||||
"withSafetyModeUserFields": False, | ||||||||||||||||
} | ||||||||||||||||
if cursor is not None: | ||||||||||||||||
variables['cursor'] = cursor | ||||||||||||||||
|
||||||||||||||||
return await self.gql_get( | ||||||||||||||||
Endpoint.BLOCKED_ACCOUNTS_ALL, variables, BLOCKED_ACCOUNTS_ALL_FEATURES | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
async def muted_accounts(self, user_id, count, cursor): | ||||||||||||||||
variables={"count":count,"includePromotedContent":False} | ||||||||||||||||
if cursor is not None: | ||||||||||||||||
variables['cursor'] = cursor | ||||||||||||||||
|
||||||||||||||||
return await self.gql_get( | ||||||||||||||||
Endpoint.MUTED_ACCOUNTS, variables, BLOCKED_ACCOUNTS_ALL_FEATURES | ||||||||||||||||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,3 +225,29 @@ | |
'longform_notetweets_inline_media_enabled': True, | ||
'responsive_web_enhance_cards_enabled': False | ||
} | ||
|
||
BLOCKED_ACCOUNTS_ALL_FEATURES = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (complexity): Consider using a single dictionary for feature flags. The introduction of the |
||
"rweb_tipjar_consumption_enabled": True, | ||
"responsive_web_graphql_exclude_directive_enabled": True, | ||
"verified_phone_label_enabled": False, | ||
"creator_subscriptions_tweet_preview_api_enabled": True, | ||
"responsive_web_graphql_timeline_navigation_enabled": True, | ||
"responsive_web_graphql_skip_user_profile_image_extensions_enabled": False, | ||
"communities_web_enable_tweet_community_results_fetch": True, | ||
"c9s_tweet_anatomy_moderator_badge_enabled": True, | ||
"articles_preview_enabled": True, | ||
"responsive_web_edit_tweet_api_enabled": True, | ||
"graphql_is_translatable_rweb_tweet_is_translatable_enabled": True, | ||
"view_counts_everywhere_api_enabled": True, | ||
"longform_notetweets_consumption_enabled": True, | ||
"responsive_web_twitter_article_tweet_consumption_enabled": True, | ||
"tweet_awards_web_tipping_enabled": False, | ||
"creator_subscriptions_quote_tweet_preview_enabled": False, | ||
"freedom_of_speech_not_reach_fetch_enabled": True, | ||
"standardized_nudges_misinfo": True, | ||
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled": True, | ||
"rweb_video_timestamps_enabled": True, | ||
"longform_notetweets_rich_text_read_enabled": True, | ||
"longform_notetweets_inline_media_enabled": True, | ||
"responsive_web_enhance_cards_enabled": False, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider refactoring get_blocked_users and get_muted_users to reduce duplication
The get_blocked_users and get_muted_users methods are very similar. Consider creating a generic method for fetching user lists and then implement these as thin wrappers around it. This would improve maintainability and reduce the chance of inconsistencies.