class DatabaseHistory

Defined in:

privateparlor/history/database_history.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(database : DB::Database, message_life : Time::Span) #

Create an instance of DatabaseHistory and create the appropriate schema in the SQLite database.


[View source]

Instance Method Detail

def add_rating(msid : Int64, uid : Int64) : Bool #

Adds a rating entry to the karma table with the given data

Returns true if the user was successfully added to the karma table; false if the user was already in it.


[View source]
def add_to_cache(origin_msid : Int64, msid : Int64, receiver_id : Int64) : Nil #

Adds receiver_id and its associated msid to the receivers table


[View source]
def add_warning(msid : Int64) : Nil #

Set the warned attribute to true in message group associated with the given MSID.


[View source]
def db : DB::Database #

[View source]
def del_message_group(msid : Int64) : Int64 | Nil #

Delete message group


[View source]
def delete_database_message_group(origin_msid : Int64 | Nil) #

[View source]
def delete_expired_messages : Nil #

[View source]
def ensure_schema : Nil #

Ensures that the DB schema for persisting message history is usable by the program.


[View source]
def expire : Nil #

Expire messages


[View source]
def get_all_msids(msid : Int64) : Hash #

Get all receivers for a message group associated with the given MSID


[View source]
def get_msid(msid : Int64, receiver_id : Int64) : Int64 | Nil #

Get receiver msid from the given MSID and receiver ID


[View source]
def get_msids_from_user(uid : Int64) : Set(Int64) #

Get all MSIDs sent by a user


[View source]
def get_origin_msid(msid : Int64) : Int64 | Nil #

Returns the messageGroupID from the given MSID, which may or may not be in in the receivers table


[View source]
def get_sender_id(msid : Int64) : Int64 | Nil #

Get sender_id of a specific message group


[View source]
def get_warning(msid : Int64) : Bool | Nil #

Returns true if the associated message group was warned; false otherwise.


[View source]
def lifespan : Time::Span #

[View source]
def new_message(sender_id : Int64, msid : Int64) : Int64 #

Adds a new entry to the message_groups table with the sender_id and its associated msid

Returns the original msid of this message group


[View source]