followability 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +19 -14
- data/config/locales/en.yml +5 -2
- data/lib/followability/followable/actions/block.rb +5 -5
- data/lib/followability/followable/actions/follow.rb +29 -0
- data/lib/followability/followable/callbacks.rb +2 -0
- data/lib/followability/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5381804ee6dcba9d0a7fcd76d2a560e9b6ff371aa3b2c4212cb394f8abbf4468
|
4
|
+
data.tar.gz: 4aae8e97665f8b10f1a1ee31d9b244d1a63fed320d7e9777249c907c215e3d5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1fab64911111ec2ef69ca06f4b173f4bd0daf4e49085fcbaae2674c6b1efac9e549ffe492ab2205eee0bc413200c09910094fa4819b914cb92a0bfbe1a6fa5
|
7
|
+
data.tar.gz: fb8e8e23c3b63158ba16e7981d85de9ee0382ee530d3b0de2194feb125e6d6ba5ed209c1c5caa12476814701e50038bd906c1b70fb19b2cc1c808d0b526636d2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -47,6 +47,7 @@ Avaiable methods:
|
|
47
47
|
- decline_follow_request_of
|
48
48
|
- remove_follow_request_for
|
49
49
|
- send_follow_request_to
|
50
|
+
- unfollow
|
50
51
|
- following?
|
51
52
|
- mutual_following_with?
|
52
53
|
- sent_follow_request_to?
|
@@ -80,27 +81,20 @@ Avaiable methods:
|
|
80
81
|
@foo.mutual_following_with?(@bar)
|
81
82
|
# => false
|
82
83
|
|
83
|
-
@foo.errors.full_messages
|
84
|
-
# => [...]
|
85
|
-
|
86
84
|
@bar.following?(@foo)
|
87
85
|
# => false
|
88
|
-
|
89
|
-
@foo.errors.full_messages
|
90
|
-
# => [...]
|
91
|
-
|
92
86
|
```
|
93
87
|
|
94
88
|
### Blocking actions
|
95
89
|
Avaiable methods:
|
96
|
-
-
|
97
|
-
-
|
90
|
+
- block
|
91
|
+
- unblock
|
98
92
|
- blocked?
|
99
93
|
- blocked_by?
|
100
94
|
|
101
95
|
### Usage
|
102
96
|
```ruby
|
103
|
-
@foo.
|
97
|
+
@foo.block(@bar)
|
104
98
|
# => true
|
105
99
|
|
106
100
|
@foo.blocked?(@bar)
|
@@ -109,7 +103,7 @@ Avaiable methods:
|
|
109
103
|
@bar.blocked_by?(@foo)
|
110
104
|
# => true
|
111
105
|
|
112
|
-
@foo.
|
106
|
+
@foo.unblock(@bar)
|
113
107
|
# => true
|
114
108
|
```
|
115
109
|
|
@@ -178,6 +172,8 @@ Available methods:
|
|
178
172
|
- followable_blocked_by_someone
|
179
173
|
- followable_unblocked_by_me
|
180
174
|
- followable_unblocked_by_someone
|
175
|
+
- unfollow_by_me
|
176
|
+
- unfollow_by_someone
|
181
177
|
- followability_triggered
|
182
178
|
|
183
179
|
### Usage
|
@@ -188,6 +184,7 @@ class User < ActiveRecord::Base
|
|
188
184
|
def follow_request_sent_to_me(record)
|
189
185
|
Notifications::FollowRequestSentToMeJob.perform_later(from_id: record.id)
|
190
186
|
end
|
187
|
+
|
191
188
|
def follow_request_sent_to_someone(record); end
|
192
189
|
def follow_request_accepted_by_me(record); end
|
193
190
|
def follow_request_accepted_by_someone(record); end
|
@@ -199,6 +196,12 @@ class User < ActiveRecord::Base
|
|
199
196
|
def followable_blocked_by_someone(record); end
|
200
197
|
def followable_unblocked_by_me(record); end
|
201
198
|
def followable_unblocked_by_someone(record); end
|
199
|
+
def unfollow_by_me(record); end
|
200
|
+
|
201
|
+
def unfollow_by_someone(record)
|
202
|
+
Followability::RemoveFollowedUser(user_id: record.id)
|
203
|
+
end
|
204
|
+
|
202
205
|
def followability_triggered(record, callback_name); end
|
203
206
|
end
|
204
207
|
```
|
@@ -206,19 +209,21 @@ end
|
|
206
209
|
## I18n
|
207
210
|
```yml
|
208
211
|
---
|
209
|
-
---
|
210
212
|
en:
|
211
213
|
followability:
|
212
214
|
errors:
|
213
215
|
block:
|
214
|
-
|
216
|
+
unblock:
|
215
217
|
myself: 'You can not run this action for yourself'
|
216
|
-
|
218
|
+
block:
|
217
219
|
myself: 'You can not run this action for yourself'
|
218
220
|
blocked_by: 'You can not block to who blocked to you'
|
219
221
|
already_blocked: '%{klass} already blocked'
|
220
222
|
not_blocked_for_blocking: 'You can not unblock to %{klass} because was not blocked'
|
221
223
|
follow:
|
224
|
+
unfollow:
|
225
|
+
myself: 'You can not run this action for yourself'
|
226
|
+
empty_relation: 'You can not unfollow to %{klass} because was not followed'
|
222
227
|
decline_follow_request_of:
|
223
228
|
myself: 'You can not run this action for yourself'
|
224
229
|
empty_relation: 'You can not decline follow request of %{klass} because was not sent'
|
data/config/locales/en.yml
CHANGED
@@ -3,14 +3,17 @@ en:
|
|
3
3
|
followability:
|
4
4
|
errors:
|
5
5
|
block:
|
6
|
-
|
6
|
+
unblock:
|
7
7
|
myself: 'You can not run this action for yourself'
|
8
|
-
|
8
|
+
block:
|
9
9
|
myself: 'You can not run this action for yourself'
|
10
10
|
blocked_by: 'You can not block to who blocked to you'
|
11
11
|
already_blocked: '%{klass} already blocked'
|
12
12
|
not_blocked_for_blocking: 'You can not unblock to %{klass} because was not blocked'
|
13
13
|
follow:
|
14
|
+
unfollow:
|
15
|
+
myself: 'You can not run this action for yourself'
|
16
|
+
empty_relation: 'You can not unfollow to %{klass} because was not followed'
|
14
17
|
decline_follow_request_of:
|
15
18
|
myself: 'You can not run this action for yourself'
|
16
19
|
empty_relation: 'You can not decline follow request of %{klass} because was not sent'
|
@@ -6,15 +6,15 @@ module Followability
|
|
6
6
|
module Block
|
7
7
|
I18N_SCOPE = 'followability.errors.block'
|
8
8
|
|
9
|
-
def
|
9
|
+
def block(record)
|
10
10
|
if myself?(record)
|
11
|
-
errors.add(:base, I18n.t('
|
11
|
+
errors.add(:base, I18n.t('block.myself', scope: I18N_SCOPE, klass: record.class))
|
12
12
|
|
13
13
|
return false
|
14
14
|
end
|
15
15
|
|
16
16
|
if blocked_by?(record)
|
17
|
-
errors.add(:base, I18n.t('
|
17
|
+
errors.add(:base, I18n.t('block.blocked_by', scope: I18N_SCOPE, klass: record.class))
|
18
18
|
|
19
19
|
return false
|
20
20
|
end
|
@@ -40,9 +40,9 @@ module Followability
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def unblock(record)
|
44
44
|
if myself?(record)
|
45
|
-
errors.add(:base, I18n.t('
|
45
|
+
errors.add(:base, I18n.t('unblock.myself', scope: I18N_SCOPE, klass: record.class))
|
46
46
|
|
47
47
|
return false
|
48
48
|
end
|
@@ -33,6 +33,35 @@ module Followability
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def unfollow(record)
|
37
|
+
if myself?(record)
|
38
|
+
errors.add(:base, I18n.t('unfollow.myself', scope: I18N_SCOPE, klass: record.class))
|
39
|
+
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
|
43
|
+
unless following?(record)
|
44
|
+
errors.add(:base, I18n.t('unfollow.not_following', scope: I18N_SCOPE, klass: record.class))
|
45
|
+
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
|
49
|
+
relation = followerable_relationships.find_by(followable_id: record.id,
|
50
|
+
followable_type: record.class.name,
|
51
|
+
status: Followable::Relationship.statuses[:following])
|
52
|
+
|
53
|
+
if relation.destroy
|
54
|
+
run_callback(self, affected: record, callback: :unfollow_by_me)
|
55
|
+
run_callback(record, affected: self, callback: :unfollow_by_someone)
|
56
|
+
|
57
|
+
true
|
58
|
+
else
|
59
|
+
errors.add(:base, relation.errors.full_messages)
|
60
|
+
|
61
|
+
false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
36
65
|
def accept_follow_request_of(record)
|
37
66
|
if myself?(record)
|
38
67
|
errors.add(:base, I18n.t('accept_follow_request_of.myself', scope: I18N_SCOPE, klass: record.class))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: followability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nejdetkadir
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Implements the social network followable functionality for your Active
|
14
14
|
Record models.
|