diff options
author | David Yip <yipdw@member.fsf.org> | 2017-11-28 11:45:13 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-11-28 11:45:13 -0600 |
commit | 95c270f5b1ffd328345a7b1223f65876f3d88423 (patch) | |
tree | 621e27e89b238d8806fdd3294009361d0691f49c /app/models | |
parent | 7463d80ff442833a4ad299460f37c27be9b8cda1 (diff) | |
parent | 15fab79cfa5b732e9d7816f162272d72cf06c733 (diff) |
Merge remote-tracking branch 'origin/master' into gs-master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/account_interactions.rb | 4 | ||||
-rw-r--r-- | app/models/form/migration.rb | 4 | ||||
-rw-r--r-- | app/models/invite.rb | 6 |
3 files changed, 8 insertions, 6 deletions
diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb index c41f92581..fdf35a4e3 100644 --- a/app/models/concerns/account_interactions.rb +++ b/app/models/concerns/account_interactions.rb @@ -7,7 +7,7 @@ module AccountInteractions def following_map(target_account_ids, account_id) Follow.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |follow, mapping| mapping[follow.target_account_id] = { - reblogs: follow.show_reblogs? + reblogs: follow.show_reblogs?, } end end @@ -31,7 +31,7 @@ module AccountInteractions def requested_map(target_account_ids, account_id) FollowRequest.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |follow_request, mapping| mapping[follow_request.target_account_id] = { - reblogs: follow_request.show_reblogs? + reblogs: follow_request.show_reblogs?, } end end diff --git a/app/models/form/migration.rb b/app/models/form/migration.rb index 53cee7ee1..b74987337 100644 --- a/app/models/form/migration.rb +++ b/app/models/form/migration.rb @@ -5,8 +5,6 @@ class Form::Migration attr_accessor :acct, :account - validates :acct, presence: true - def initialize(attrs = {}) @account = attrs[:account] @acct = attrs[:account].acct unless @account.nil? @@ -22,6 +20,6 @@ class Form::Migration private def set_account - self.account = ResolveRemoteAccountService.new.call(acct) if account.nil? && acct.present? + self.account = (ResolveRemoteAccountService.new.call(acct) if account.nil? && acct.present?) end end diff --git a/app/models/invite.rb b/app/models/invite.rb index ceca04686..7626f4cfa 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -27,13 +27,17 @@ class Invite < ApplicationRecord end def valid_for_use? - (max_uses.nil? || uses < max_uses) && (expires_at.nil? || expires_at >= Time.now.utc) + (max_uses.nil? || uses < max_uses) && !expired? end def expire! touch(:expires_at) end + def expired? + !expires_at.nil? && expires_at < Time.now.utc + end + private def set_code |