Class: Async::Matrix::Bridge::Discord::DB::Portal
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- Async::Matrix::Bridge::Discord::DB::Portal
- Defined in:
- lib/async/matrix/bridge/discord/db/portal.rb
Overview
Maps a Discord channel to a Matrix room.
Uses a composite primary key of (discord_id, receiver). For guild channels, receiver is an empty string. For DMs, receiver is the Discord user ID of the bridge user who owns the portal.
portal = Portal.create(discord_id: "chan123", receiver: "", mxid: "!room:x")
portal.guild # => Guild or nil
portal. # => [Message, ...]
Instance Method Summary collapse
-
#dm? ⇒ Boolean
Is this a DM portal? (has a receiver).
-
#guild_channel? ⇒ Boolean
Is this a guild channel portal?.
- #validate ⇒ Object
Instance Method Details
#dm? ⇒ Boolean
Is this a DM portal? (has a receiver)
43 44 45 |
# File 'lib/async/matrix/bridge/discord/db/portal.rb', line 43 def dm? receiver && !receiver.empty? end |
#guild_channel? ⇒ Boolean
Is this a guild channel portal?
48 49 50 |
# File 'lib/async/matrix/bridge/discord/db/portal.rb', line 48 def guild_channel? !dm? end |
#validate ⇒ Object
37 38 39 40 |
# File 'lib/async/matrix/bridge/discord/db/portal.rb', line 37 def validate super errors.add(:discord_id, "cannot be empty") if discord_id.nil? || discord_id.empty? end |