01a692ab5b
Added tests for the word filter store. Added qgen.NewAcc() to reduce the amount of boilerplate needed for creating an accumulator. Exposed the RecordError method on the accumulator. Added an Add method to PluginList and removed AddPlugin() in favour of that. More panel buttons on Nox should be styled now. Added the panel_update_button_text phrase for future use. More errors might be caught in the thumbnailer now. Removed ls from .travis.yml, it was there for debugging Code Climate.
28 lines
762 B
Go
28 lines
762 B
Go
package common
|
|
|
|
import "database/sql"
|
|
import "../query_gen/lib"
|
|
|
|
var Subscriptions SubscriptionStore
|
|
|
|
// ? Should we have a subscription store for each zone? topic, forum, etc?
|
|
type SubscriptionStore interface {
|
|
Add(uid int, elementID int, elementType string) error
|
|
}
|
|
|
|
type DefaultSubscriptionStore struct {
|
|
add *sql.Stmt
|
|
}
|
|
|
|
func NewDefaultSubscriptionStore() (*DefaultSubscriptionStore, error) {
|
|
acc := qgen.NewAcc()
|
|
return &DefaultSubscriptionStore{
|
|
add: acc.Insert("activity_subscriptions").Columns("user, targetID, targetType, level").Fields("?,?,?,2").Prepare(),
|
|
}, acc.FirstError()
|
|
}
|
|
|
|
func (store *DefaultSubscriptionStore) Add(uid int, elementID int, elementType string) error {
|
|
_, err := store.add.Exec(uid, elementID, elementType)
|
|
return err
|
|
}
|