Module: TurboChat::Permission::MentionSupport
- Included in:
- TurboChat::Permission
- Defined in:
- lib/turbo_chat/permission/mention_support.rb
Instance Method Summary collapse
- #can_mention_all? ⇒ Boolean
- #can_mention_members? ⇒ Boolean
- #can_mention_roles? ⇒ Boolean
- #can_mention_token?(token) ⇒ Boolean
Instance Method Details
#can_mention_all? ⇒ Boolean
5 |
# File 'lib/turbo_chat/permission/mention_support.rb', line 5 def can_mention_all? = can_view_chat? && (:mention_all) |
#can_mention_members? ⇒ Boolean
3 |
# File 'lib/turbo_chat/permission/mention_support.rb', line 3 def can_mention_members? = can_view_chat? && (:mention_member) |
#can_mention_roles? ⇒ Boolean
7 |
# File 'lib/turbo_chat/permission/mention_support.rb', line 7 def can_mention_roles? = can_view_chat? && (:mention_role) |
#can_mention_token?(token) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/turbo_chat/permission/mention_support.rb', line 9 def can_mention_token?(token) mention = token.to_s.strip return false if mention.blank? return false unless mention.start_with?("@") return can_mention_all? if mention.casecmp("@all").zero? return can_mention_roles? if ROLE_MENTION_TOKEN_PATTERN.match?(mention) return can_mention_members? if MEMBER_MENTION_TOKEN_PATTERN.match?(mention) false end |