Changeset 441 in code for trunk


Ignore:
Timestamp:
Jan 4, 2021, 4:17:35 PM (4 years ago)
Author:
contact
Message:

Make chat history operations optional in messageStore

Some stores may want not to implement chat history operations.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r440 r441  
    17361736                }
    17371737
    1738                 if dc.user.msgStore == nil {
     1738                store, ok := dc.user.msgStore.(chatHistoryMessageStore)
     1739                if !ok {
    17391740                        return ircError{&irc.Message{
    17401741                                Command: irc.ERR_UNKNOWNCOMMAND,
     
    17761777                switch subcommand {
    17771778                case "BEFORE":
    1778                         history, err = dc.user.msgStore.LoadBeforeTime(uc.network, entity, timestamp, limit)
     1779                        history, err = store.LoadBeforeTime(uc.network, entity, timestamp, limit)
    17791780                case "AFTER":
    1780                         history, err = dc.user.msgStore.LoadAfterTime(uc.network, entity, timestamp, limit)
     1781                        history, err = store.LoadAfterTime(uc.network, entity, timestamp, limit)
    17811782                default:
    17821783                        // TODO: support LATEST, BETWEEN
  • trunk/msgstore.go

    r440 r441  
    1717        // used in history queries.
    1818        LastMsgID(network *network, entity string, t time.Time) (string, error)
     19        LoadLatestID(network *network, entity, id string, limit int) ([]*irc.Message, error)
     20        Append(network *network, entity string, msg *irc.Message) (id string, err error)
     21}
     22
     23// chatHistoryMessageStore is a message store that supports chat history
     24// operations.
     25type chatHistoryMessageStore interface {
     26        messageStore
     27
    1928        LoadBeforeTime(network *network, entity string, t time.Time, limit int) ([]*irc.Message, error)
    2029        LoadAfterTime(network *network, entity string, t time.Time, limit int) ([]*irc.Message, error)
    21         LoadLatestID(network *network, entity, id string, limit int) ([]*irc.Message, error)
    22         Append(network *network, entity string, msg *irc.Message) (id string, err error)
    2330}
    2431
Note: See TracChangeset for help on using the changeset viewer.