diff options
Diffstat (limited to 'registry/index.go')
-rw-r--r-- | registry/index.go | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/registry/index.go b/registry/index.go index c3ea178..c5f8d2c 100644 --- a/registry/index.go +++ b/registry/index.go @@ -5,11 +5,6 @@ import ( "time" ) -// NewUserIndex returns a new instance of a user index -func NewUserIndex() *UserIndex { - return &UserIndex{} -} - // AddUser inserts a new user into the index. The *Data struct // contains the nickname and the time the user was added. func (index UserIndex) AddUser(nick string, url string) { @@ -28,3 +23,24 @@ func (index UserIndex) DelUser(url string) { delete(index, url) imutex.Unlock() } + +// GetUserStatuses returns a TimeMap containing a user's statuses +func (index UserIndex) GetUserStatuses(url string) TimeMap { + imutex.RLock() + status := index[url].Status + imutex.RUnlock() + return status +} + +// GetStatuses returns a TimeMap containing all statuses +func (index UserIndex) GetStatuses() TimeMap { + statuses := NewTimeMap() + imutex.RLock() + for _, v := range index { + for a, b := range v.Status { + statuses[a] = b + } + } + imutex.RUnlock() + return statuses +} |