gosora/tasks.go
Azareal 31f506c50c Removed the images for Cosmo from /images/, it's very saddening to see it go :(
Moved Reload from the UserStore into the UserCache.
Replaced many of the calls to Reload with CacheRemove.
Simplified the error functions.
Fixed a bug in the errors where they didn't have any CSS. Oops.
Added CustomErrorJS(), unused for now, but it may be useful in the future, especially for plugins.
Fixed many problems in the themes.
Added the Stick(), Unstick(), CreateActionReply(), Lock() and Unlock() methods to *Topic.
Renamed ip-search.html to ip-search-results.html
Added the Activate() and initPerms methods to *User.

Tempra Cursive is hiding from sight for this one commit.
Added Font Awesome to /public/, it isn't used yet.
2017-09-22 03:21:17 +01:00

78 lines
1.3 KiB
Go

/*
*
* Gosora Task System
* Copyright Azareal 2017 - 2018
*
*/
package main
import "time"
var lastSync time.Time
func init() {
lastSync = time.Now()
}
func handleExpiredScheduledGroups() error {
rows, err := getExpiredScheduledGroupsStmt.Query()
if err != nil {
return err
}
defer rows.Close()
var uid int
ucache, ok := users.(UserCache)
for rows.Next() {
err := rows.Scan(&uid)
if err != nil {
return err
}
_, err = replaceScheduleGroupStmt.Exec(uid, 0, 0, time.Now(), false)
if err != nil {
return err
}
_, err = setTempGroupStmt.Exec(0, uid)
if err != nil {
return err
}
if ok {
ucache.CacheRemove(uid)
}
}
return rows.Err()
}
func handleServerSync() error {
var lastUpdate time.Time
var lastUpdateStr string
err := getSyncStmt.QueryRow().Scan(&lastUpdateStr)
if err != nil {
return err
}
lastUpdate, err = time.Parse("2006-01-02 15:04:05", lastUpdateStr)
if err != nil {
return err
}
if lastUpdate.After(lastSync) {
// TODO: A more granular sync
err = fstore.LoadForums()
if err != nil {
return err
}
// TODO: Resync the groups
// TODO: Resync the permissions
err = LoadSettings()
if err != nil {
return err
}
err = LoadWordFilters()
if err != nil {
return err
}
}
return nil
}