double the number of cached noavatars
|
@ -268,9 +268,9 @@ func ProcessConfig() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !Config.DisableDefaultNoavatar {
|
if !Config.DisableDefaultNoavatar {
|
||||||
noavatarCache200 = make([]string, 5)
|
noavatarCache200 = make([]string, 10)
|
||||||
noavatarCache48 = make([]string, 5)
|
noavatarCache48 = make([]string, 10)
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 11; i++ {
|
||||||
noavatarCache200[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".png?i=0"
|
noavatarCache200[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(200) + ".png?i=0"
|
||||||
noavatarCache48[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".png?i=0"
|
noavatarCache48[i] = StaticFiles.Prefix + "n" + strconv.Itoa(i) + "-" + strconv.Itoa(48) + ".png?i=0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,8 +235,8 @@ func (u *User) CacheRemove() {
|
||||||
TopicListThaw.Thaw()
|
TopicListThaw.Thaw()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) Ban(duration time.Duration, issuedBy int) error {
|
func (u *User) Ban(dur time.Duration, issuedBy int) error {
|
||||||
return u.ScheduleGroupUpdate(BanGroup, issuedBy, duration)
|
return u.ScheduleGroupUpdate(BanGroup, issuedBy, dur)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) Unban() error {
|
func (u *User) Unban() error {
|
||||||
|
@ -244,30 +244,30 @@ func (u *User) Unban() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) deleteScheduleGroupTx(tx *sql.Tx) error {
|
func (u *User) deleteScheduleGroupTx(tx *sql.Tx) error {
|
||||||
deleteScheduleGroupStmt, err := qgen.Builder.SimpleDeleteTx(tx, "users_groups_scheduler", "uid=?")
|
deleteScheduleGroupStmt, e := qgen.Builder.SimpleDeleteTx(tx, "users_groups_scheduler", "uid=?")
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
_, err = deleteScheduleGroupStmt.Exec(u.ID)
|
_, e = deleteScheduleGroupStmt.Exec(u.ID)
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) setTempGroupTx(tx *sql.Tx, tempGroup int) error {
|
func (u *User) setTempGroupTx(tx *sql.Tx, tempGroup int) error {
|
||||||
setTempGroupStmt, err := qgen.Builder.SimpleUpdateTx(tx, "users", "temp_group=?", "uid=?")
|
setTempGroupStmt, e := qgen.Builder.SimpleUpdateTx(tx, "users", "temp_group=?", "uid=?")
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
_, err = setTempGroupStmt.Exec(tempGroup, u.ID)
|
_, e = setTempGroupStmt.Exec(tempGroup, u.ID)
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make this more stateless?
|
// Make this more stateless?
|
||||||
func (u *User) ScheduleGroupUpdate(gid, issuedBy int, duration time.Duration) error {
|
func (u *User) ScheduleGroupUpdate(gid, issuedBy int, dur time.Duration) error {
|
||||||
var temp bool
|
var temp bool
|
||||||
if duration.Nanoseconds() != 0 {
|
if dur.Nanoseconds() != 0 {
|
||||||
temp = true
|
temp = true
|
||||||
}
|
}
|
||||||
revertAt := time.Now().Add(duration)
|
revertAt := time.Now().Add(dur)
|
||||||
|
|
||||||
tx, err := qgen.Builder.Begin()
|
tx, err := qgen.Builder.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -300,46 +300,46 @@ func (u *User) ScheduleGroupUpdate(gid, issuedBy int, duration time.Duration) er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) RevertGroupUpdate() error {
|
func (u *User) RevertGroupUpdate() error {
|
||||||
tx, err := qgen.Builder.Begin()
|
tx, e := qgen.Builder.Begin()
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
defer tx.Rollback()
|
defer tx.Rollback()
|
||||||
|
|
||||||
err = u.deleteScheduleGroupTx(tx)
|
e = u.deleteScheduleGroupTx(tx)
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
err = u.setTempGroupTx(tx, 0)
|
e = u.setTempGroupTx(tx, 0)
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
err = tx.Commit()
|
e = tx.Commit()
|
||||||
|
|
||||||
u.CacheRemove()
|
u.CacheRemove()
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use a transaction here
|
// TODO: Use a transaction here
|
||||||
// ? - Add a Deactivate method? Not really needed, if someone's been bad you could do a ban, I guess it might be useful, if someone says that email x isn't actually owned by the user in question?
|
// ? - Add a Deactivate method? Not really needed, if someone's been bad you could do a ban, I guess it might be useful, if someone says that email x isn't actually owned by the user in question?
|
||||||
func (u *User) Activate() (err error) {
|
func (u *User) Activate() (e error) {
|
||||||
_, err = userStmts.activate.Exec(u.ID)
|
_, e = userStmts.activate.Exec(u.ID)
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
_, err = userStmts.changeGroup.Exec(Config.DefaultGroup, u.ID)
|
_, e = userStmts.changeGroup.Exec(Config.DefaultGroup, u.ID)
|
||||||
u.CacheRemove()
|
u.CacheRemove()
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Write tests for this
|
// TODO: Write tests for this
|
||||||
// TODO: Delete this user's content too?
|
// TODO: Delete this user's content too?
|
||||||
// TODO: Expose this to the admin?
|
// TODO: Expose this to the admin?
|
||||||
func (u *User) Delete() error {
|
func (u *User) Delete() error {
|
||||||
_, err := userStmts.delete.Exec(u.ID)
|
_, e := userStmts.delete.Exec(u.ID)
|
||||||
if err != nil {
|
if e != nil {
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
u.CacheRemove()
|
u.CacheRemove()
|
||||||
return nil
|
return nil
|
||||||
|
@ -514,18 +514,18 @@ func (u *User) DeletePosts() error {
|
||||||
return rows.Err()
|
return rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) bindStmt(stmt *sql.Stmt, params ...interface{}) (err error) {
|
func (u *User) bindStmt(stmt *sql.Stmt, params ...interface{}) (e error) {
|
||||||
params = append(params, u.ID)
|
params = append(params, u.ID)
|
||||||
_, err = stmt.Exec(params...)
|
_, e = stmt.Exec(params...)
|
||||||
u.CacheRemove()
|
u.CacheRemove()
|
||||||
return err
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) ChangeName(name string) (err error) {
|
func (u *User) ChangeName(name string) error {
|
||||||
return u.bindStmt(userStmts.setName, name)
|
return u.bindStmt(userStmts.setName, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) ChangeAvatar(avatar string) (err error) {
|
func (u *User) ChangeAvatar(avatar string) error {
|
||||||
return u.bindStmt(userStmts.setAvatar, avatar)
|
return u.bindStmt(userStmts.setAvatar, avatar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ func (u *User) ScheduleAvatarResize() (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) ChangeGroup(group int) (err error) {
|
func (u *User) ChangeGroup(group int) error {
|
||||||
return u.bindStmt(userStmts.changeGroup, group)
|
return u.bindStmt(userStmts.changeGroup, group)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,9 +623,9 @@ func (u *User) IncreasePostStats(wcount int, topic bool) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) countf(stmt *sql.Stmt) (count int) {
|
func (u *User) countf(stmt *sql.Stmt) (count int) {
|
||||||
err := stmt.QueryRow().Scan(&count)
|
e := stmt.QueryRow().Scan(&count)
|
||||||
if err != nil {
|
if e != nil {
|
||||||
LogError(err)
|
LogError(e)
|
||||||
}
|
}
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
@ -684,8 +684,8 @@ func (u *User) DecreasePostStats(wcount int, topic bool) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) ResetPostStats() (err error) {
|
func (u *User) ResetPostStats() error {
|
||||||
_, err = userStmts.resetStats.Exec(u.ID)
|
_, err := userStmts.resetStats.Exec(u.ID)
|
||||||
u.CacheRemove()
|
u.CacheRemove()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 2.5 KiB |
|
@ -16,8 +16,7 @@ func main() {
|
||||||
|
|
||||||
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
|
||||||
defer func() {
|
defer func() {
|
||||||
r := recover()
|
if r := recover(); r != nil {
|
||||||
if r != nil {
|
|
||||||
fmt.Println(r)
|
fmt.Println(r)
|
||||||
debug.PrintStack()
|
debug.PrintStack()
|
||||||
pressAnyKey(scanner)
|
pressAnyKey(scanner)
|
||||||
|
|