pairing

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 11 Imported by: 0

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

View Source
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

func Record(home string, r Request) error

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

func Remove(home, channel, senderID string) error

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

func RemoveChannel(home, channel string) error

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.

func List

func List(home, channel string) ([]Request, error)

List returns the pending requests of channel, most recently seen first. An empty channel lists the requests of every channel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL