f7942b42ac
Trying to add support for Travis CI. Added the NullUserStore for tests. Moved more text out of the templates. Removed an unnecessary dependency for Cosora. Fixed a few more bugs in the MSSQL Adapter. Disabled upserts for now, as it isn't working on MySQL. Refactored the scheduled group logic to reduce the number of potential bugs and to stop using upserts. Fixed many bugs in the Markdown Plugin. Added the ability to escape Markdown. Fixed a number of tests, commented unneccesary ones, and added new ones to probe for new problems. Added the wink smiley. Cleaned up some of the JavaScript. Refactored the permissions logic to use transactions and avoid duplicating logic. Added the ChangeRank method to the Group struct. Added the ChangeGroup method to the User struct. Added the currently unused LogWarning function. Added the transaction versions of the builder methods. Better ones coming up soon! The IsBanned flag is always set to false on mod and admin groups now. Refactored the group creation logic to use transactions. Fixed a bug in the group creator where new groups aren't visible to Exists(). The installer now drops tables for MySQL Databases, if they already exist to make it easier for us to run automated tests. Added more ARIA Attributes.
74 lines
1.2 KiB
Go
74 lines
1.2 KiB
Go
/*
|
|
*
|
|
* Gosora Task System
|
|
* Copyright Azareal 2017 - 2018
|
|
*
|
|
*/
|
|
package main
|
|
|
|
import (
|
|
"log"
|
|
"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
|
|
for rows.Next() {
|
|
err := rows.Scan(&uid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Sneaky way of initialising a *User, please use the methods on the UserStore instead
|
|
user := getDummyUser()
|
|
user.ID = uid
|
|
err = user.RevertGroupUpdate()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return rows.Err()
|
|
}
|
|
|
|
func handleServerSync() error {
|
|
var lastUpdate time.Time
|
|
err := getSyncStmt.QueryRow().Scan(&lastUpdate)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if lastUpdate.After(lastSync) {
|
|
// TODO: A more granular sync
|
|
err = fstore.LoadForums()
|
|
if err != nil {
|
|
log.Print("Unable to reload the forums")
|
|
return err
|
|
}
|
|
// TODO: Resync the groups
|
|
// TODO: Resync the permissions
|
|
err = LoadSettings()
|
|
if err != nil {
|
|
log.Print("Unable to reload the settings")
|
|
return err
|
|
}
|
|
err = LoadWordFilters()
|
|
if err != nil {
|
|
log.Print("Unable to reload the word filters")
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|