votes: make private favorites and upvotes a Gold-only option.

Make private favorites and upvotes a Gold-only account option.

Existing Members with private favorites enabled are allowed to keep it
enabled, as long as they don't disable it. If they disable it, then they
can't re-enable it again without upgrading to Gold first.

This is a Gold-only option to prevent uploaders from creating multiple
accounts to upvote their own posts. If private upvotes were allowed for
Members, then it would be too easy to use fake accounts and private
upvotes to upvote your own posts.
This commit is contained in:
evazion
2021-11-16 17:09:06 -06:00
parent 055e5939b4
commit bc96eb864b
5 changed files with 57 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ module HasBitFlags
def has_bit_flags(attributes, field: :bit_flags)
attributes.each.with_index do |attribute, i|
bit_flag = 1 << i
field_was = "#{field}_was"
define_method(attribute) do
send(field) & bit_flag > 0
@@ -15,6 +16,14 @@ module HasBitFlags
send(field) & bit_flag > 0
end
define_method("#{attribute}_was") do
send(field_was) & bit_flag > 0
end
define_method("#{attribute}_was?") do
send(field_was) & bit_flag > 0
end
define_method("#{attribute}=") do |val|
if val.to_s =~ /[t1y]/
send("#{field}=", send(field) | bit_flag)