class

PrivateParlorXT::SQLiteHistory

Inherits PrivateParlorXT::History < Reference < Object

An implementation of History using the SQLite Database for storing message data

Constructors

new(lifespan : Time::Span, connection : DB::Database)

Initialize a SQLiteHistory where messages older than lifespan are considered expired

Generally this should use the same connection that was used for the database

Source

Instance methods

add_rating(message : MessageID, user : UserID) : Bool

Adds a rating entry to the database with the given data

Returns true if the user's rating was successfully added; false if the user's rating already exists.

Source
add_to_history(origin : MessageID, receiver : MessageID, receiver_id : UserID) : Nil

Add a receiver message to the History

Source
add_warning(message : MessageID) : Nil

Adds a warning to the given message

Source
close

Closes the databsase connection

Source
delete_message_group(message : MessageID) : MessageID | Nil

Delete a message group from the History

Source
ensure_schema

Ensures that there are message_group, receivers, and karma tables in the Database

Source
expire

Deletes old messages from the History

This should be invoked as a recurring task

Source
messages_from_user(user : UserID) : Set(MessageID)

Get all message IDs sent by a given user for purging messages

Source
new_message(sender_id : UserID, origin : MessageID) : MessageID

Create a new message group and add it to the History

Source
origin_message(message : MessageID) : MessageID | Nil

Get the message ID of the original message associated with the given message ID

Source
purge_receivers(messages : Set(MessageID)) : Hash(UserID, Array(MessageID))

Get a hash containing an array of message IDs to delete associated with the users who received a message in the given set. Used for the PurgeCommand NOTE: The returned array of message IDs should be sorted in descending order (most recent messages first)

Source
receiver_message(message : MessageID, receiver : UserID) : MessageID | Nil

Get the original message ID associated with the given message ID and receiver ID

Source
receivers(message : MessageID) : Hash(UserID, MessageID)

Get a hash of all users and receiver message IDs associated with the given message ID

Source
sender(message : MessageID) : UserID | Nil

Get the sender of the original message referenced by the given message ID

Source
warned?(message : MessageID) : Bool | Nil

Returns true if the given message was already warned; false or nil otherwise

Source