2018-01-22 08:15:45 +00:00
|
|
|
package common
|
|
|
|
|
2019-09-29 04:56:39 +00:00
|
|
|
import (
|
2022-02-21 03:53:13 +00:00
|
|
|
"database/sql"
|
2019-09-29 04:56:39 +00:00
|
|
|
|
2022-02-21 03:53:13 +00:00
|
|
|
qgen "git.tuxpa.in/a/gosora/query_gen"
|
2019-09-29 04:56:39 +00:00
|
|
|
)
|
2018-01-22 08:15:45 +00:00
|
|
|
|
|
|
|
var Subscriptions SubscriptionStore
|
|
|
|
|
|
|
|
// ? Should we have a subscription store for each zone? topic, forum, etc?
|
|
|
|
type SubscriptionStore interface {
|
2022-02-21 03:32:53 +00:00
|
|
|
Add(uid, elementID int, elementType string) error
|
|
|
|
Delete(uid, targetID int, targetType string) error
|
|
|
|
DeleteResource(targetID int, targetType string) error
|
2018-01-22 08:15:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DefaultSubscriptionStore struct {
|
2022-02-21 03:32:53 +00:00
|
|
|
add *sql.Stmt
|
|
|
|
delete *sql.Stmt
|
|
|
|
deleteResource *sql.Stmt
|
2018-01-22 08:15:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewDefaultSubscriptionStore() (*DefaultSubscriptionStore, error) {
|
2022-02-21 03:32:53 +00:00
|
|
|
acc := qgen.NewAcc()
|
|
|
|
ast := "activity_subscriptions"
|
|
|
|
return &DefaultSubscriptionStore{
|
|
|
|
add: acc.Insert(ast).Columns("user,targetID,targetType,level").Fields("?,?,?,2").Prepare(),
|
|
|
|
delete: acc.Delete(ast).Where("user=? AND targetID=? AND targetType=?").Prepare(),
|
|
|
|
deleteResource: acc.Delete(ast).Where("targetID=? AND targetType=?").Prepare(),
|
|
|
|
}, acc.FirstError()
|
2018-01-22 08:15:45 +00:00
|
|
|
}
|
|
|
|
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
func (s *DefaultSubscriptionStore) Add(uid, elementID int, elementType string) error {
|
2022-02-21 03:32:53 +00:00
|
|
|
_, err := s.add.Exec(uid, elementID, elementType)
|
|
|
|
return err
|
2018-01-22 08:15:45 +00:00
|
|
|
}
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
|
|
|
|
// TODO: Add a primary key to the activity subscriptions table
|
|
|
|
func (s *DefaultSubscriptionStore) Delete(uid, targetID int, targetType string) error {
|
2022-02-21 03:32:53 +00:00
|
|
|
_, err := s.delete.Exec(uid, targetID, targetType)
|
|
|
|
return err
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DefaultSubscriptionStore) DeleteResource(targetID int, targetType string) error {
|
2022-02-21 03:32:53 +00:00
|
|
|
_, err := s.deleteResource.Exec(targetID, targetType)
|
|
|
|
return err
|
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
|
|
|
}
|