Module: X::Resources::Actions::Relationships
- Included in:
- X::Resources::API
- Defined in:
- x-resources/lib/x/resources/actions/relationships.rb
Overview
Follow, block, and mute users as the authenticated user
Internal to x-resources: X::Resources::API includes it, and its methods are public API of the client that includes API, but the module is only how they are grouped, and some of them need the methods of another, so include API rather than this module alone.
Instance Method Summary collapse
-
#block(user) ⇒ Boolean
Block a user as the authenticated user.
-
#follow(user) ⇒ Boolean
Follow a user as the authenticated user.
-
#mute(user) ⇒ Boolean
Mute a user as the authenticated user.
-
#unblock(user) ⇒ Boolean
Unblock a user as the authenticated user.
-
#unfollow(user) ⇒ Boolean
Unfollow a user as the authenticated user.
-
#unmute(user) ⇒ Boolean
Unmute a user as the authenticated user.
Instance Method Details
#block(user) ⇒ Boolean
Block a user as the authenticated user
52 53 54 |
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 52 def block(user) RelationWrites.relate(self, current_user_id, "blocking", {"target_user_id" => Utils.id_of(user, User)}, "blocking") end |
#follow(user) ⇒ Boolean
Follow a user as the authenticated user
A protected user must accept a request to follow them first, so for a protected user true means the follow was requested, not that the authenticated user follows them: until they accept it, the follows? of the authenticated user, as in client.current_user!.follows?(user), answers false.
30 31 32 |
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 30 def follow(user) RelationWrites.relate(self, current_user_id, "following", {"target_user_id" => Utils.id_of(user, User)}, "following", "pending_follow") end |
#mute(user) ⇒ Boolean
Mute a user as the authenticated user
74 75 76 |
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 74 def mute(user) RelationWrites.relate(self, current_user_id, "muting", {"target_user_id" => Utils.id_of(user, User)}, "muting") end |
#unblock(user) ⇒ Boolean
Unblock a user as the authenticated user
63 64 65 |
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 63 def unblock(user) RelationWrites.unrelate(self, current_user_id, "blocking", Utils.id_of(user, User), "blocking") end |
#unfollow(user) ⇒ Boolean
Unfollow a user as the authenticated user
41 42 43 |
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 41 def unfollow(user) RelationWrites.unrelate(self, current_user_id, "following", Utils.id_of(user, User), "following") end |
#unmute(user) ⇒ Boolean
Unmute a user as the authenticated user
85 86 87 |
# File 'x-resources/lib/x/resources/actions/relationships.rb', line 85 def unmute(user) RelationWrites.unrelate(self, current_user_id, "muting", Utils.id_of(user, User), "muting") end |