Skip to content

Commit e062049

Browse files
committed
Refactor community membership check in EventInvitation and add primary community accessor in PrimaryCommunity
1 parent e0ee11d commit e062049

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/models/better_together/event_invitation.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ def invitee_uniqueness_for_event
115115
end
116116

117117
def ensure_community_membership!(person)
118-
return unless event&.creator&.community
118+
community = BetterTogether::Community.find_by(host: true)
119119

120-
community = event.creator.community
121-
return if community.person_community_memberships.exists?(member: person)
120+
return unless community
122121

123122
# Create community membership for the invitee
124123
default_role = BetterTogether::Role.find_by(identifier: 'community_member')

app/models/concerns/better_together/primary_community.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ def primary_community_extra_attrs
4848
{}
4949
end
5050

51+
# Backwards-compatible accessor used in tests and callers expecting a `primary_community` method
52+
def primary_community
53+
community
54+
end
55+
5156
def after_record_created; end
5257

5358
def to_s

0 commit comments

Comments
 (0)