Documentation
¶
Overview ¶
Package pairing keeps the direct messages a channel received while its allow_from listed no account. Such a message is not processed; the channel records the sender here, and the owner approves their own account in the dashboard, which adds SenderID to the channel's allow_from and drops the channel's other requests. Once allow_from lists an account, the channel records no more.
The requests live in pairing.json in the Compa home. Each channel keeps at most MaxPendingPerChannel of them: a new sender beyond that replaces the one seen longest ago. A request whose sender has been silent for Expiry is dropped.
Index ¶
Constants ¶
const ( // FileName is the store's file in the Compa home. FileName = "pairing.json" // MaxPendingPerChannel bounds the requests kept for one channel. MaxPendingPerChannel = 3 // Expiry is how long a request is kept after its sender's last message. Expiry = time.Hour )
Variables ¶
This section is empty.
Functions ¶
func Record ¶
Record stores r, or updates the request already stored for the same Channel and SenderID: its LastSeen moves forward, Count grows by r.Count (one when unset), and a non-empty PlatformID or DisplayName replaces the stored one. Zero FirstSeen and LastSeen mean now.
func Remove ¶
Remove deletes the request of senderID on channel, as approving or rejecting it does. Removing a request that is not stored is not an error.
func RemoveChannel ¶
RemoveChannel deletes every request held for channel, as binding the channel's owner does.
Types ¶
type Request ¶
type Request struct {
// Channel is the channel's name in channel_list.
Channel string `json:"channel"`
// SenderID is the value to append to the channel's allow_from: the
// canonical "platform:id" form the allow_from matching accepts.
SenderID string `json:"sender_id"`
// PlatformID is the sender's id on the platform, for display.
PlatformID string `json:"platform_id,omitempty"`
// DisplayName is the name the sender shows on the platform.
DisplayName string `json:"display_name,omitempty"`
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
// Count is how many messages the sender sent while waiting.
Count int `json:"count"`
}
Request is one sender waiting for the owner's approval.