2017-09-13 15:09:13 +00:00
/ *
*
* Gosora Topic File
2019-02-10 05:52:26 +00:00
* Copyright Azareal 2017 - 2020
2017-09-13 15:09:13 +00:00
*
* /
2017-11-10 03:33:11 +00:00
package common
2017-09-03 04:50:31 +00:00
2017-09-28 22:16:34 +00:00
import (
2017-11-11 04:06:16 +00:00
"database/sql"
2017-12-30 10:07:57 +00:00
"html"
2017-09-28 22:16:34 +00:00
"html/template"
2019-10-06 11:32:00 +00:00
2017-09-28 22:16:34 +00:00
"strconv"
2019-05-17 08:40:41 +00:00
"strings"
2017-10-14 07:39:22 +00:00
"time"
2017-11-11 04:06:16 +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
//"log"
2019-05-17 08:40:41 +00:00
p "github.com/Azareal/Gosora/common/phrases"
2019-10-06 11:32:00 +00:00
qgen "github.com/Azareal/Gosora/query_gen"
2017-09-28 22:16:34 +00:00
)
2017-11-08 07:28:33 +00:00
// This is also in reply.go
//var ErrAlreadyLiked = errors.New("This item was already liked by this user")
2017-09-28 22:16:34 +00:00
// ? - Add a TopicMeta struct for *Forums?
2016-12-02 07:38:54 +00:00
2017-09-03 04:50:31 +00:00
type Topic struct {
2018-12-27 05:42:41 +00:00
ID int
Link string
Title string
Content string
CreatedBy int
IsClosed bool
Sticky bool
CreatedAt time . Time
LastReplyAt time . Time
LastReplyBy int
LastReplyID int
ParentID int
2020-08-15 02:37:56 +00:00
Status string // Deprecated. Marked for removal. -Is there anything we could use it for?
2019-10-06 11:32:00 +00:00
IP string
2018-12-27 05:42:41 +00:00
ViewCount int64
PostCount int
LikeCount int
AttachCount int
2021-01-02 21:46:24 +00:00
WeekViews int
2018-12-27 05:42:41 +00:00
ClassName string // CSS Class Name
Poll int
Data string // Used for report metadata
2019-05-17 08:40:41 +00:00
Rids [ ] int
2016-12-02 07:38:54 +00:00
}
2017-09-03 04:50:31 +00:00
type TopicUser struct {
2018-12-27 05:42:41 +00:00
ID int
Link string
Title string
Content string // TODO: Avoid converting this to bytes in templates, particularly if it's long
CreatedBy int
IsClosed bool
Sticky bool
CreatedAt time . Time
LastReplyAt time . Time
LastReplyBy int
LastReplyID int
ParentID int
Status string // Deprecated. Marked for removal.
2019-10-06 11:32:00 +00:00
IP string
2018-12-27 05:42:41 +00:00
ViewCount int64
PostCount int
LikeCount int
AttachCount int
ClassName string
Poll int
Data string // Used for report metadata
2017-06-05 11:57:27 +00:00
2017-09-03 04:50:31 +00:00
UserLink string
2016-12-03 05:00:21 +00:00
CreatedByName string
2017-09-03 04:50:31 +00:00
Group int
Avatar string
2018-07-28 12:52:23 +00:00
MicroAvatar string
2017-09-03 04:50:31 +00:00
ContentLines int
2018-11-28 21:46:53 +00:00
ContentHTML string // TODO: Avoid converting this to bytes in templates, particularly if it's long
2017-09-03 04:50:31 +00:00
Tag string
URL string
2019-12-08 03:40:56 +00:00
//URLPrefix string
//URLName string
Level int
Liked bool
2018-12-27 05:42:41 +00:00
Attachments [ ] * MiniAttachment
2019-05-17 08:40:41 +00:00
Rids [ ] int
2019-10-06 11:32:00 +00:00
Deletable bool
2016-12-03 05:00:21 +00:00
}
2017-02-06 04:52:19 +00:00
2020-07-19 03:26:56 +00:00
type TopicsRowMut struct {
* TopicsRow
CanMod bool
}
2019-05-17 08:40:41 +00:00
// TODO: Embed TopicUser to simplify this structure and it's related logic?
2017-09-03 04:50:31 +00:00
type TopicsRow struct {
2020-08-15 02:37:56 +00:00
Topic
LastPage int
2017-09-03 04:50:31 +00:00
Creator * User
CSS template . CSS
2017-02-06 04:52:19 +00:00
ContentLines int
2017-09-03 04:50:31 +00:00
LastUser * User
2017-06-05 11:57:27 +00:00
2017-02-06 04:52:19 +00:00
ForumName string //TopicsRow
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
ForumLink string
2017-02-06 04:52:19 +00:00
}
2017-02-11 14:51:16 +00:00
2018-06-24 13:49:29 +00:00
type WsTopicsRow struct {
ID int
Link string
Title string
CreatedBy int
IsClosed bool
Sticky bool
CreatedAt time . Time
LastReplyAt time . Time
RelativeLastReplyAt string
LastReplyBy int
2018-12-27 05:42:41 +00:00
LastReplyID int
2018-06-24 13:49:29 +00:00
ParentID int
2018-09-08 01:32:24 +00:00
ViewCount int64
2018-06-24 13:49:29 +00:00
PostCount int
LikeCount int
2018-12-27 05:42:41 +00:00
AttachCount int
2018-06-24 13:49:29 +00:00
ClassName string
Creator * WsJSONUser
LastUser * WsJSONUser
ForumName string
ForumLink string
2020-07-19 03:26:56 +00:00
CanMod bool
2018-06-24 13:49:29 +00:00
}
2018-12-27 05:42:41 +00:00
// TODO: Can we get the client side to render the relative times instead?
2019-08-31 22:34:43 +00:00
func ( r * TopicsRow ) WebSockets ( ) * WsTopicsRow {
2020-07-19 03:26:56 +00:00
return & WsTopicsRow { r . ID , r . Link , r . Title , r . CreatedBy , r . IsClosed , r . Sticky , r . CreatedAt , r . LastReplyAt , RelativeTime ( r . LastReplyAt ) , r . LastReplyBy , r . LastReplyID , r . ParentID , r . ViewCount , r . PostCount , r . LikeCount , r . AttachCount , r . ClassName , r . Creator . WebSockets ( ) , r . LastUser . WebSockets ( ) , r . ForumName , r . ForumLink , false }
}
// TODO: Can we get the client side to render the relative times instead?
func ( r * TopicsRow ) WebSockets2 ( canMod bool ) * WsTopicsRow {
return & WsTopicsRow { r . ID , r . Link , r . Title , r . CreatedBy , r . IsClosed , r . Sticky , r . CreatedAt , r . LastReplyAt , RelativeTime ( r . LastReplyAt ) , r . LastReplyBy , r . LastReplyID , r . ParentID , r . ViewCount , r . PostCount , r . LikeCount , r . AttachCount , r . ClassName , r . Creator . WebSockets ( ) , r . LastUser . WebSockets ( ) , r . ForumName , r . ForumLink , canMod }
2018-06-24 13:49:29 +00:00
}
2019-02-23 06:29:19 +00:00
// TODO: Stop relying on so many struct types?
// ! Not quite safe as Topic doesn't contain all the data needed to constructs a TopicsRow
func ( t * Topic ) TopicsRow ( ) * TopicsRow {
lastPage := 1
var creator * User = nil
contentLines := 1
var lastUser * User = nil
forumName := ""
forumLink := ""
2020-08-15 02:37:56 +00:00
//return &TopicsRow{t.ID, t.Link, t.Title, t.Content, t.CreatedBy, t.IsClosed, t.Sticky, t.CreatedAt, t.LastReplyAt, t.LastReplyBy, t.LastReplyID, t.ParentID, t.Status, t.IP, t.ViewCount, t.PostCount, t.LikeCount, t.AttachCount, lastPage, t.ClassName, t.Poll, t.Data, creator, "", contentLines, lastUser, forumName, forumLink, t.Rids}
return & TopicsRow { * t , lastPage , creator , "" , contentLines , lastUser , forumName , forumLink }
2019-05-17 08:40:41 +00:00
}
// ! Some data may be lost in the conversion
2020-08-15 02:37:56 +00:00
/ * func ( t * TopicsRow ) Topic ( ) * Topic {
//return &Topic{t.ID, t.Link, t.Title, t.Content, t.CreatedBy, t.IsClosed, t.Sticky, t.CreatedAt, t.LastReplyAt, t.LastReplyBy, t.LastReplyID, t.ParentID, t.Status, t.IP, t.ViewCount, t.PostCount, t.LikeCount, t.AttachCount, t.ClassName, t.Poll, t.Data, t.Rids}
return & t . Topic
} * /
2019-02-23 06:29:19 +00:00
// ! Not quite safe as Topic doesn't contain all the data needed to constructs a WsTopicsRow
/ * func ( t * Topic ) WsTopicsRows ( ) * WsTopicsRow {
var creator * User = nil
var lastUser * User = nil
forumName := ""
forumLink := ""
return & WsTopicsRow { t . ID , t . Link , t . Title , t . CreatedBy , t . IsClosed , t . Sticky , t . CreatedAt , t . LastReplyAt , RelativeTime ( t . LastReplyAt ) , t . LastReplyBy , t . LastReplyID , t . ParentID , t . ViewCount , t . PostCount , t . LikeCount , t . AttachCount , t . ClassName , creator , lastUser , forumName , forumLink }
} * /
2017-11-11 04:06:16 +00:00
type TopicStmts struct {
2020-01-23 06:17:50 +00:00
getRids * sql . Stmt
getReplies * sql . Stmt
2020-04-27 12:41:55 +00:00
getReplies2 * sql . Stmt
getReplies3 * sql . Stmt
2020-01-23 06:17:50 +00:00
addReplies * sql . Stmt
updateLastReply * sql . Stmt
lock * sql . Stmt
unlock * sql . Stmt
moveTo * sql . Stmt
stick * sql . Stmt
unstick * sql . Stmt
hasLikedTopic * sql . Stmt
createLike * sql . Stmt
addLikesToTopic * sql . Stmt
delete * sql . Stmt
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
deleteReplies * sql . Stmt
2020-01-15 04:16:10 +00:00
deleteLikesForTopic * sql . Stmt
2020-01-23 06:17:50 +00:00
deleteActivity * sql . Stmt
edit * sql . Stmt
setPoll * sql . Stmt
createAction * sql . Stmt
2017-11-11 04:06:16 +00:00
getTopicUser * sql . Stmt // TODO: Can we get rid of this?
2018-01-20 06:50:29 +00:00
getByReplyID * sql . Stmt
2017-11-11 04:06:16 +00:00
}
var topicStmts TopicStmts
func init ( ) {
2017-11-12 03:29:05 +00:00
DbInits . Add ( func ( acc * qgen . Accumulator ) error {
2019-10-28 07:46:14 +00:00
t := "topics"
2017-11-11 04:06:16 +00:00
topicStmts = TopicStmts {
2020-02-20 04:32:49 +00:00
getRids : acc . Select ( "replies" ) . Columns ( "rid" ) . Where ( "tid=?" ) . Orderby ( "rid ASC" ) . Limit ( "?,?" ) . Prepare ( ) ,
2020-04-27 12:41:55 +00:00
getReplies : acc . SimpleLeftJoin ( "replies AS r" , "users AS u" , "r.rid, r.content, r.createdBy, r.createdAt, r.lastEdit, r.lastEditBy, u.avatar, u.name, u.group, u.level, r.ip, r.likeCount, r.attachCount, r.actionType" , "r.createdBy=u.uid" , "r.tid=?" , "r.rid ASC" , "?,?" ) ,
getReplies2 : acc . SimpleLeftJoin ( "replies AS r" , "users AS u" , "r.rid, r.content, r.createdBy, r.createdAt, r.lastEdit, r.lastEditBy, u.avatar, u.name, u.group, u.level, r.likeCount, r.attachCount, r.actionType" , "r.createdBy=u.uid" , "r.tid=?" , "r.rid ASC" , "?,?" ) ,
getReplies3 : acc . Select ( "replies" ) . Columns ( "rid, content, createdBy, createdAt, lastEdit, lastEditBy, likeCount, attachCount, actionType" ) . Where ( "tid=?" ) . Orderby ( "rid ASC" ) . Limit ( "?,?" ) . Prepare ( ) ,
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
addReplies : acc . Update ( t ) . Set ( "postCount=postCount+?, lastReplyBy=?, lastReplyAt=UTC_TIMESTAMP()" ) . Where ( "tid=?" ) . Prepare ( ) ,
2021-03-24 20:01:40 +00:00
updateLastReply : acc . Update ( t ) . Set ( "lastReplyID=?" ) . Where ( "lastReplyID < ? AND tid=?" ) . Prepare ( ) ,
2020-01-23 06:17:50 +00:00
lock : acc . Update ( t ) . Set ( "is_closed=1" ) . Where ( "tid=?" ) . Prepare ( ) ,
unlock : acc . Update ( t ) . Set ( "is_closed=0" ) . Where ( "tid=?" ) . Prepare ( ) ,
moveTo : acc . Update ( t ) . Set ( "parentID=?" ) . Where ( "tid=?" ) . Prepare ( ) ,
stick : acc . Update ( t ) . Set ( "sticky=1" ) . Where ( "tid=?" ) . Prepare ( ) ,
unstick : acc . Update ( t ) . Set ( "sticky=0" ) . Where ( "tid=?" ) . Prepare ( ) ,
hasLikedTopic : acc . Select ( "likes" ) . Columns ( "targetItem" ) . Where ( "sentBy=? and targetItem=? and targetType='topics'" ) . Prepare ( ) ,
createLike : acc . Insert ( "likes" ) . Columns ( "weight, targetItem, targetType, sentBy, createdAt" ) . Fields ( "?,?,?,?,UTC_TIMESTAMP()" ) . Prepare ( ) ,
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
addLikesToTopic : acc . Update ( t ) . Set ( "likeCount=likeCount+?" ) . Where ( "tid=?" ) . Prepare ( ) ,
2020-01-23 06:17:50 +00:00
delete : acc . Delete ( t ) . Where ( "tid=?" ) . Prepare ( ) ,
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
deleteReplies : acc . Delete ( "replies" ) . Where ( "tid=?" ) . Prepare ( ) ,
2020-01-23 06:17:50 +00:00
deleteLikesForTopic : acc . Delete ( "likes" ) . Where ( "targetItem=? AND targetType='topics'" ) . Prepare ( ) ,
deleteActivity : acc . Delete ( "activity_stream" ) . Where ( "elementID=? AND elementType='topic'" ) . Prepare ( ) ,
edit : acc . Update ( t ) . Set ( "title=?,content=?,parsed_content=?" ) . Where ( "tid=?" ) . Prepare ( ) , // TODO: Only run the content update bits on non-polls, does this matter?
setPoll : acc . Update ( t ) . Set ( "poll=?" ) . Where ( "tid=? AND poll=0" ) . Prepare ( ) ,
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
createAction : acc . Insert ( "replies" ) . Columns ( "tid, actionType, ip, createdBy, createdAt, lastUpdated, content, parsed_content" ) . Fields ( "?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),'',''" ) . Prepare ( ) ,
2018-12-27 05:42:41 +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
getTopicUser : acc . SimpleLeftJoin ( "topics AS t" , "users AS u" , "t.title, t.content, t.createdBy, t.createdAt, t.lastReplyAt, t.lastReplyBy, t.lastReplyID, t.is_closed, t.sticky, t.parentID, t.ip, t.views, t.postCount, t.likeCount, t.attachCount,t.poll, u.name, u.avatar, u.group, u.level" , "t.createdBy=u.uid" , "tid=?" , "" , "" ) ,
getByReplyID : acc . SimpleLeftJoin ( "replies AS r" , "topics AS t" , "t.tid, t.title, t.content, t.createdBy, t.createdAt, t.is_closed, t.sticky, t.parentID, t.ip, t.views, t.postCount, t.likeCount, t.poll, t.data" , "r.tid=t.tid" , "rid=?" , "" , "" ) ,
2017-11-11 04:06:16 +00:00
}
return acc . FirstError ( )
} )
}
2017-11-08 07:28:33 +00:00
// Flush the topic out of the cache
// ? - We do a CacheRemove() here instead of mutating the pointer to avoid creating a race condition
2019-08-31 22:34:43 +00:00
func ( t * Topic ) cacheRemove ( ) {
2019-10-19 10:33:59 +00:00
if tc := Topics . GetCache ( ) ; tc != nil {
tc . Remove ( t . ID )
2017-09-22 02:21:17 +00:00
}
2018-11-19 23:06:15 +00:00
TopicListThaw . Thaw ( )
2017-11-08 07:28:33 +00:00
}
// TODO: Write a test for this
2019-12-08 03:40:56 +00:00
func ( t * Topic ) AddReply ( rid , uid int ) ( err error ) {
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . addReplies . Exec ( 1 , uid , t . ID )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . updateLastReply . Exec ( rid , rid , t . ID )
t . cacheRemove ( )
2017-11-08 07:28:33 +00:00
return err
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Lock ( ) ( err error ) {
_ , err = topicStmts . lock . Exec ( t . ID )
t . cacheRemove ( )
2017-09-22 02:21:17 +00:00
return err
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Unlock ( ) ( err error ) {
_ , err = topicStmts . unlock . Exec ( t . ID )
t . cacheRemove ( )
2017-09-22 02:21:17 +00:00
return err
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) MoveTo ( destForum int ) ( err error ) {
_ , err = topicStmts . moveTo . Exec ( destForum , t . ID )
t . cacheRemove ( )
2019-04-13 11:54:22 +00:00
if err != nil {
return err
}
2019-08-31 22:34:43 +00:00
err = Attachments . MoveTo ( destForum , t . ID , "topics" )
2019-04-13 11:54:22 +00:00
if err != nil {
return err
}
2019-08-31 22:34:43 +00:00
return Attachments . MoveToByExtra ( destForum , "replies" , strconv . Itoa ( t . ID ) )
2018-01-14 12:03:20 +00:00
}
2017-09-22 02:21:17 +00:00
// TODO: We might want more consistent terminology rather than using stick in some places and pin in others. If you don't understand the difference, there is none, they are one and the same.
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Stick ( ) ( err error ) {
_ , err = topicStmts . stick . Exec ( t . ID )
t . cacheRemove ( )
2017-09-22 02:21:17 +00:00
return err
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Unstick ( ) ( err error ) {
_ , err = topicStmts . unstick . Exec ( t . ID )
t . cacheRemove ( )
2017-09-22 02:21:17 +00:00
return err
}
2017-11-08 07:28:33 +00:00
// TODO: Test this
// TODO: Use a transaction for this
2019-12-08 03:40:56 +00:00
func ( t * Topic ) Like ( score , uid int ) ( err error ) {
2018-03-31 05:25:27 +00:00
var disp int // Unused
2019-08-31 22:34:43 +00:00
err = topicStmts . hasLikedTopic . QueryRow ( uid , t . ID ) . Scan ( & disp )
2017-11-08 07:28:33 +00:00
if err != nil && err != ErrNoRows {
return err
} else if err != ErrNoRows {
return ErrAlreadyLiked
}
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . createLike . Exec ( score , t . ID , "topics" , uid )
2017-11-08 07:28:33 +00:00
if err != nil {
return err
}
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . addLikesToTopic . Exec ( 1 , t . ID )
2018-03-31 05:25:27 +00:00
if err != nil {
return err
}
2019-10-06 22:20:37 +00:00
_ , err = userStmts . incLiked . Exec ( 1 , uid )
2019-08-31 22:34:43 +00:00
t . cacheRemove ( )
2017-11-08 07:28:33 +00:00
return err
2017-09-22 02:21:17 +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: Use a transaction
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Unlike ( uid int ) error {
2020-02-01 05:55:33 +00:00
err := Likes . Delete ( t . ID , "topics" )
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
if err != nil {
return err
}
_ , err = topicStmts . addLikesToTopic . Exec ( - 1 , t . ID )
if err != nil {
return err
}
_ , err = userStmts . decLiked . Exec ( 1 , uid )
2019-08-31 22:34:43 +00:00
t . cacheRemove ( )
2020-01-31 10:48:55 +00:00
return err
2017-09-22 02:21:17 +00:00
}
2020-01-18 08:12:00 +00:00
func handleLikedTopicReplies ( tid int ) error {
rows , err := userStmts . getLikedRepliesOfTopic . Query ( tid )
if err != nil {
return err
}
defer rows . Close ( )
for rows . Next ( ) {
var rid int
err := rows . Scan ( & rid )
if err != nil {
return err
}
_ , err = replyStmts . deleteLikesForReply . Exec ( rid )
if err != nil {
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
err = Activity . DeleteByParams ( "like" , rid , "post" )
if err != nil {
return err
}
2020-01-18 08:12:00 +00:00
}
return rows . Err ( )
}
2020-01-23 06:17:50 +00:00
func handleTopicAttachments ( tid int ) error {
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
err := handleAttachments ( userStmts . getAttachmentsOfTopic , tid )
if err != nil {
return err
}
return handleAttachments ( userStmts . getAttachmentsOfTopic2 , tid )
}
func handleReplyAttachments ( rid int ) error {
return handleAttachments ( replyStmts . getAidsOfReply , rid )
}
func handleAttachments ( stmt * sql . Stmt , id int ) error {
rows , err := stmt . Query ( id )
if err != nil {
return err
}
defer rows . Close ( )
for rows . Next ( ) {
var aid int
err := rows . Scan ( & aid )
2020-01-23 06:17:50 +00:00
if err != nil {
return err
}
2020-02-20 04:32:49 +00:00
a , err := Attachments . FGet ( aid )
if err != nil {
return err
}
err = deleteAttachment ( a )
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
if err != nil && err != sql . ErrNoRows {
return err
2020-01-23 06:17:50 +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
return rows . Err ( )
}
// TODO: Only load a row per createdBy, maybe with group by?
2020-02-04 11:47:03 +00:00
func handleTopicReplies ( umap map [ int ] struct { } , uid , tid int ) error {
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
rows , err := userStmts . getRepliesOfTopic . Query ( uid , tid )
2020-01-23 06:17:50 +00:00
if err != nil {
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
defer rows . Close ( )
2020-06-09 02:04:58 +00:00
var createdBy int
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
for rows . Next ( ) {
err := rows . Scan ( & createdBy )
if err != nil {
return err
}
umap [ createdBy ] = struct { } { }
}
return rows . Err ( )
2020-01-23 06:17:50 +00:00
}
2017-10-30 09:57:08 +00:00
// TODO: Use a transaction here
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Delete ( ) error {
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
/ * creator , err := Users . Get ( t . CreatedBy )
2017-10-30 09:57:08 +00:00
if err == nil {
2020-01-18 08:12:00 +00:00
err = creator . DecreasePostStats ( WordCount ( t . Content ) , true )
2017-10-30 09:57:08 +00:00
if err != nil {
return err
}
} else if err != ErrNoRows {
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
} * /
2017-10-30 09:57:08 +00:00
2020-01-14 05:07:00 +00:00
// TODO: Clear reply cache too
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
_ , err := topicStmts . delete . Exec ( t . ID )
2019-08-31 22:34:43 +00:00
t . cacheRemove ( )
2019-05-06 04:04:00 +00:00
if err != nil {
return err
}
2019-10-31 23:17:26 +00:00
err = Forums . RemoveTopic ( t . ParentID )
if err != nil && err != ErrNoRows {
return err
}
2020-01-15 04:16:10 +00:00
_ , err = topicStmts . deleteLikesForTopic . Exec ( t . ID )
if err != nil {
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
if t . PostCount > 1 {
err = handleLikedTopicReplies ( t . ID )
if err != nil {
return err
}
umap := make ( map [ int ] struct { } )
err = handleTopicReplies ( umap , t . CreatedBy , t . ID )
if err != nil {
return err
}
_ , err = topicStmts . deleteReplies . Exec ( t . ID )
if err != nil {
return err
}
for uid := range umap {
err = ( & User { ID : uid } ) . RecalcPostStats ( )
if err != nil {
//log.Printf("err: %+v\n", err)
return err
}
}
}
err = ( & User { ID : t . CreatedBy } ) . RecalcPostStats ( )
2020-01-18 08:12:00 +00:00
if err != nil {
return err
}
2020-01-23 06:17:50 +00:00
err = handleTopicAttachments ( t . ID )
if err != nil {
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
err = Subscriptions . DeleteResource ( t . ID , "topic" )
2019-05-06 04:04:00 +00:00
if err != nil {
return err
}
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . deleteActivity . Exec ( t . ID )
2020-01-20 06:58:22 +00:00
if err != nil {
return err
}
if t . Poll > 0 {
2020-01-23 06:17:50 +00:00
err = ( & Poll { ID : t . Poll } ) . Delete ( )
2020-01-20 06:58:22 +00:00
if err != nil {
return err
}
}
return nil
2017-10-30 09:57:08 +00:00
}
2017-12-30 10:07:57 +00:00
// TODO: Write tests for this
2019-12-08 03:40:56 +00:00
func ( t * Topic ) Update ( name , content string ) error {
2018-05-31 06:51:31 +00:00
name = SanitiseSingleLine ( html . UnescapeString ( name ) )
2018-03-17 08:16:43 +00:00
if name == "" {
return ErrNoTitle
}
// ? This number might be a little screwy with Unicode, but it's the only consistent thing we have, as Unicode characters can be any number of bytes in theory?
if len ( name ) > Config . MaxTopicTitleLength {
return ErrLongTitle
}
2017-12-30 10:07:57 +00:00
content = PreparseMessage ( html . UnescapeString ( content ) )
2020-02-04 11:47:03 +00:00
parsedContent := ParseMessage ( content , t . ParentID , "forums" , nil , nil )
2019-08-31 22:34:43 +00:00
_ , err := topicStmts . edit . Exec ( name , content , parsedContent , t . ID )
t . cacheRemove ( )
2017-09-28 22:16:34 +00:00
return err
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) SetPoll ( pollID int ) error {
_ , err := topicStmts . setPoll . Exec ( pollID , t . ID ) // TODO: Sniff if this changed anything to see if we hit an existing poll
t . cacheRemove ( )
2018-01-25 04:57:33 +00:00
return err
}
2017-11-11 04:06:16 +00:00
// TODO: Have this go through the ReplyStore?
2020-02-04 11:47:03 +00:00
func ( t * Topic ) CreateActionReply ( action , ip string , uid int ) ( err error ) {
2020-01-02 21:52:41 +00:00
if Config . DisablePostIP {
2020-02-04 11:47:03 +00:00
ip = ""
2020-01-02 21:52:41 +00:00
}
2019-08-31 22:34:43 +00:00
res , err := topicStmts . createAction . Exec ( t . ID , action , ip , uid )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . addReplies . Exec ( 1 , uid , t . ID )
2018-12-27 05:42:41 +00:00
if err != nil {
return err
}
lid , err := res . LastInsertId ( )
2017-09-22 02:21:17 +00:00
if err != nil {
return err
}
2018-12-27 05:42:41 +00:00
rid := int ( lid )
2019-08-31 22:34:43 +00:00
_ , err = topicStmts . updateLastReply . Exec ( rid , rid , t . ID )
t . cacheRemove ( )
2017-09-22 02:21:17 +00:00
// ? - Update the last topic cache for the parent forum?
return err
}
2019-12-08 03:40:56 +00:00
func GetRidsForTopic ( tid , offset int ) ( rids [ ] int , err error ) {
2019-05-17 08:40:41 +00:00
rows , err := topicStmts . getRids . Query ( tid , offset , Config . ItemsPerPage )
if err != nil {
return nil , err
}
defer rows . Close ( )
var rid int
for rows . Next ( ) {
err := rows . Scan ( & rid )
if err != nil {
return nil , err
}
rids = append ( rids , rid )
}
return rids , rows . Err ( )
}
2019-07-28 23:19:46 +00:00
var aipost = ";︎"
2019-10-06 11:32:00 +00:00
var lockai = "🔒" + aipost
2019-07-28 23:19:46 +00:00
var unlockai = "🔓"
var stickai = "📌"
2019-10-06 11:32:00 +00:00
var unstickai = "📌" + aipost
2020-04-27 12:41:55 +00:00
func ( ru * ReplyUser ) Init ( u * User ) ( group * Group , err error ) {
2019-05-17 08:40:41 +00:00
ru . ContentLines = strings . Count ( ru . Content , "\n" )
postGroup , err := Groups . Get ( ru . Group )
if err != nil {
2020-02-04 11:47:03 +00:00
return nil , err
2019-05-17 08:40:41 +00:00
}
if postGroup . IsMod {
ru . ClassName = Config . StaffCSS
}
2019-10-30 05:53:35 +00:00
ru . Tag = postGroup . Tag
2019-05-17 08:40:41 +00:00
2020-04-27 12:41:55 +00:00
if u . ID != ru . CreatedBy {
ru . UserLink = BuildProfileURL ( NameToSlug ( ru . CreatedByName ) , ru . CreatedBy )
// TODO: Make a function for this? Build a more sophisticated noavatar handling system? Do bulk user loads and let the c.UserStore initialise this?
ru . Avatar , ru . MicroAvatar = BuildAvatar ( ru . CreatedBy , ru . Avatar )
} else {
ru . UserLink = u . Link
ru . Avatar , ru . MicroAvatar = u . Avatar , u . MicroAvatar
}
2019-05-17 08:40:41 +00:00
// We really shouldn't have inline HTML, we should do something about this...
if ru . ActionType != "" {
aarr := strings . Split ( ru . ActionType , "-" )
2019-12-08 03:40:56 +00:00
action := aarr [ 0 ]
switch action {
2019-05-17 08:40:41 +00:00
case "lock" :
2019-07-28 23:19:46 +00:00
ru . ActionIcon = lockai
2019-05-17 08:40:41 +00:00
case "unlock" :
2019-07-28 23:19:46 +00:00
ru . ActionIcon = unlockai
2019-05-17 08:40:41 +00:00
case "stick" :
2019-07-28 23:19:46 +00:00
ru . ActionIcon = stickai
2019-05-17 08:40:41 +00:00
case "unstick" :
2019-07-28 23:19:46 +00:00
ru . ActionIcon = unstickai
2019-05-17 08:40:41 +00:00
case "move" :
if len ( aarr ) == 2 {
fid , _ := strconv . Atoi ( aarr [ 1 ] )
forum , err := Forums . Get ( fid )
if err == nil {
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_move_dest" , forum . Link , forum . Name , ru . UserLink , ru . CreatedByName )
2020-02-04 11:47:03 +00:00
return postGroup , nil
2019-05-17 08:40:41 +00:00
}
}
default :
// TODO: Only fire this off if a corresponding phrase for the ActionType doesn't exist? Or maybe have some sort of action registry?
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_default" , ru . ActionType )
2020-02-04 11:47:03 +00:00
return postGroup , nil
2019-05-17 08:40:41 +00:00
}
2019-12-08 03:40:56 +00:00
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_" + action , ru . UserLink , ru . CreatedByName )
2019-05-17 08:40:41 +00:00
}
2020-02-04 11:47:03 +00:00
return postGroup , nil
2019-05-17 08:40:41 +00:00
}
2020-04-27 12:41:55 +00:00
func ( ru * ReplyUser ) Init2 ( ) ( group * Group , err error ) {
//ru.UserLink = BuildProfileURL(NameToSlug(ru.CreatedByName), ru.CreatedBy)
ru . ContentLines = strings . Count ( ru . Content , "\n" )
postGroup , err := Groups . Get ( ru . Group )
if err != nil {
2020-06-29 11:40:52 +00:00
return postGroup , err
2020-04-27 12:41:55 +00:00
}
if postGroup . IsMod {
ru . ClassName = Config . StaffCSS
2019-05-17 08:40:41 +00:00
}
2020-04-27 12:41:55 +00:00
ru . Tag = postGroup . Tag
2019-05-17 08:40:41 +00:00
2020-04-27 12:41:55 +00:00
// We really shouldn't have inline HTML, we should do something about this...
if ru . ActionType != "" {
aarr := strings . Split ( ru . ActionType , "-" )
action := aarr [ 0 ]
switch action {
case "lock" :
ru . ActionIcon = lockai
case "unlock" :
ru . ActionIcon = unlockai
case "stick" :
ru . ActionIcon = stickai
case "unstick" :
ru . ActionIcon = unstickai
case "move" :
if len ( aarr ) == 2 {
fid , _ := strconv . Atoi ( aarr [ 1 ] )
forum , err := Forums . Get ( fid )
if err == nil {
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_move_dest" , forum . Link , forum . Name , ru . UserLink , ru . CreatedByName )
return postGroup , nil
}
}
default :
// TODO: Only fire this off if a corresponding phrase for the ActionType doesn't exist? Or maybe have some sort of action registry?
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_default" , ru . ActionType )
return postGroup , nil
}
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_" + action , ru . UserLink , ru . CreatedByName )
2019-05-17 08:40:41 +00:00
}
2020-04-27 12:41:55 +00:00
return postGroup , nil
}
func ( ru * ReplyUser ) Init3 ( u * User , tu * TopicUser ) ( group * Group , err error ) {
ru . ContentLines = strings . Count ( ru . Content , "\n" )
postGroup , err := Groups . Get ( ru . Group )
if err != nil {
2020-06-29 11:40:52 +00:00
return postGroup , err
2020-04-27 12:41:55 +00:00
}
if postGroup . IsMod {
ru . ClassName = Config . StaffCSS
}
ru . Tag = postGroup . Tag
if u . ID == ru . CreatedBy {
ru . UserLink = u . Link
ru . Avatar , ru . MicroAvatar = u . Avatar , u . MicroAvatar
} else if tu . CreatedBy == ru . CreatedBy {
ru . UserLink = tu . UserLink
ru . Avatar , ru . MicroAvatar = tu . Avatar , tu . MicroAvatar
} else {
ru . UserLink = BuildProfileURL ( NameToSlug ( ru . CreatedByName ) , ru . CreatedBy )
// TODO: Make a function for this? Build a more sophisticated noavatar handling system? Do bulk user loads and let the c.UserStore initialise this?
ru . Avatar , ru . MicroAvatar = BuildAvatar ( ru . CreatedBy , ru . Avatar )
}
// We really shouldn't have inline HTML, we should do something about this...
if ru . ActionType != "" {
aarr := strings . Split ( ru . ActionType , "-" )
action := aarr [ 0 ]
switch action {
case "lock" :
ru . ActionIcon = lockai
2020-06-09 02:04:58 +00:00
action = "topic.action_topic_lock"
2020-04-27 12:41:55 +00:00
case "unlock" :
ru . ActionIcon = unlockai
2020-06-09 02:04:58 +00:00
action = "topic.action_topic_unlock"
2020-04-27 12:41:55 +00:00
case "stick" :
ru . ActionIcon = stickai
2020-06-09 02:04:58 +00:00
action = "topic.action_topic_stick"
2020-04-27 12:41:55 +00:00
case "unstick" :
ru . ActionIcon = unstickai
2020-06-09 02:04:58 +00:00
action = "topic.action_topic_unstick"
2020-04-27 12:41:55 +00:00
case "move" :
if len ( aarr ) == 2 {
fid , _ := strconv . Atoi ( aarr [ 1 ] )
forum , err := Forums . Get ( fid )
if err == nil {
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_move_dest" , forum . Link , forum . Name , ru . UserLink , ru . CreatedByName )
return postGroup , nil
}
}
default :
// TODO: Only fire this off if a corresponding phrase for the ActionType doesn't exist? Or maybe have some sort of action registry?
ru . ActionType = p . GetTmplPhrasef ( "topic.action_topic_default" , ru . ActionType )
return postGroup , nil
}
2020-06-09 02:04:58 +00:00
ru . ActionType = p . GetTmplPhrasef ( action , ru . UserLink , ru . CreatedByName )
2020-04-27 12:41:55 +00:00
}
return postGroup , nil
}
// TODO: Factor TopicUser into a *Topic and *User, as this starting to become overly complicated x.x
2020-06-09 02:04:58 +00:00
func ( t * TopicUser ) Replies ( offset int /*pFrag int, */ , user * User ) ( rlist [ ] * ReplyUser /*, ogdesc string*/ , externalHead bool , err error ) {
2020-04-27 12:41:55 +00:00
var likedMap , attachMap map [ int ] int
var likedQueryList , attachQueryList [ ] int
2019-05-17 08:40:41 +00:00
var rid int
2019-08-31 22:34:43 +00:00
if len ( t . Rids ) > 0 {
2019-05-17 08:40:41 +00:00
//log.Print("have rid")
2019-08-31 22:34:43 +00:00
rid = t . Rids [ 0 ]
2019-05-17 08:40:41 +00:00
}
re , err := Rstore . GetCache ( ) . Get ( rid )
ucache := Users . GetCache ( )
var ruser * User
2020-04-27 12:41:55 +00:00
if ucache != nil {
2019-05-17 08:40:41 +00:00
//log.Print("ucache step")
2020-04-27 12:41:55 +00:00
if err == nil {
ruser = ucache . Getn ( re . CreatedBy )
} else if t . PostCount == 2 {
ruser = ucache . Getn ( t . LastReplyBy )
}
2019-05-17 08:40:41 +00:00
}
hTbl := GetHookTable ( )
2020-04-27 12:41:55 +00:00
rf := func ( r * ReplyUser ) ( err error ) {
2020-02-01 05:55:33 +00:00
//log.Printf("before r: %+v\n", r)
2020-06-29 11:40:52 +00:00
postGroup , err := r . Init3 ( user , t )
2019-05-17 08:40:41 +00:00
if err != nil {
2019-12-08 03:40:56 +00:00
return err
2019-05-17 08:40:41 +00:00
}
2020-02-01 05:55:33 +00:00
//log.Printf("after r: %+v\n", r)
2020-02-04 11:47:03 +00:00
var parseSettings * ParseSettings
2020-06-29 11:40:52 +00:00
if ( Config . NoEmbed || ! postGroup . Perms . AutoEmbed ) && ( user . ParseSettings == nil || ! user . ParseSettings . NoEmbed ) {
2020-02-04 11:47:03 +00:00
parseSettings = DefaultParseSettings . CopyPtr ( )
parseSettings . NoEmbed = true
} else {
parseSettings = user . ParseSettings
}
2021-03-24 20:01:40 +00:00
/ * if user . ParseSettings == nil {
parseSettings = DefaultParseSettings . CopyPtr ( )
parseSettings . NoEmbed = Config . NoEmbed || ! postGroup . Perms . AutoEmbed
parseSettings . NoLink = ! postGroup . Perms . AutoLink
} else {
parseSettings = user . ParseSettings
} * /
2020-02-04 11:47:03 +00:00
2020-06-25 02:36:06 +00:00
var eh bool
r . ContentHtml , eh = ParseMessage2 ( r . Content , t . ParentID , "forums" , parseSettings , user )
if eh {
externalHead = true
}
2019-05-22 04:45:07 +00:00
// TODO: Do this more efficiently by avoiding the allocations entirely in ParseMessage, if there's nothing to do.
2019-12-08 03:40:56 +00:00
if r . ContentHtml == r . Content {
r . ContentHtml = r . Content
2019-05-22 04:45:07 +00:00
}
2020-04-27 12:41:55 +00:00
r . Deletable = user . Perms . DeleteReply || r . CreatedBy == user . ID
2019-05-17 08:40:41 +00:00
2019-12-08 03:40:56 +00:00
// TODO: This doesn't work properly so pick the first one instead?
2020-03-09 07:11:58 +00:00
/ * if r . ID == pFrag {
2019-12-08 03:40:56 +00:00
ogdesc = r . Content
2019-05-17 08:40:41 +00:00
if len ( ogdesc ) > 200 {
ogdesc = ogdesc [ : 197 ] + "..."
}
2020-03-09 07:11:58 +00:00
} * /
2019-05-17 08:40:41 +00:00
2020-04-27 12:41:55 +00:00
return nil
}
rf3 := func ( r * ReplyUser ) error {
//log.Printf("before r: %+v\n", r)
2020-06-29 11:40:52 +00:00
postGroup , err := r . Init2 ( )
2020-04-27 12:41:55 +00:00
if err != nil {
return err
2019-05-17 08:40:41 +00:00
}
2020-04-27 12:41:55 +00:00
var parseSettings * ParseSettings
2020-06-29 11:40:52 +00:00
if ( Config . NoEmbed || ! postGroup . Perms . AutoEmbed ) && ( user . ParseSettings == nil || ! user . ParseSettings . NoEmbed ) {
2020-04-27 12:41:55 +00:00
parseSettings = DefaultParseSettings . CopyPtr ( )
parseSettings . NoEmbed = true
} else {
parseSettings = user . ParseSettings
}
2020-06-25 02:36:06 +00:00
var eh bool
r . ContentHtml , eh = ParseMessage2 ( r . Content , t . ParentID , "forums" , parseSettings , user )
if eh {
externalHead = true
}
2020-04-27 12:41:55 +00:00
// TODO: Do this more efficiently by avoiding the allocations entirely in ParseMessage, if there's nothing to do.
if r . ContentHtml == r . Content {
r . ContentHtml = r . Content
2019-05-17 08:40:41 +00:00
}
2019-12-08 03:40:56 +00:00
r . Deletable = user . Perms . DeleteReply || r . CreatedBy == user . ID
2019-05-17 08:40:41 +00:00
2019-12-08 03:40:56 +00:00
return nil
}
// TODO: Factor the user fields out and embed a user struct instead
2020-04-27 12:41:55 +00:00
if err == nil && ruser != nil {
2019-12-08 03:40:56 +00:00
//log.Print("reply cached serve")
2020-04-27 12:41:55 +00:00
r := & ReplyUser { /*ClassName: "", */ Reply : * re , CreatedByName : ruser . Name , UserLink : ruser . Link , Avatar : ruser . Avatar , MicroAvatar : ruser . MicroAvatar /*URLPrefix: ruser.URLPrefix, URLName: ruser.URLName, */ , Group : ruser . Group , Level : ruser . Level , Tag : ruser . Tag }
if err = rf3 ( r ) ; err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
if r . LikeCount > 0 && user . Liked > 0 {
2020-06-09 02:04:58 +00:00
likedMap = map [ int ] int { r . ID : 0 }
2020-04-27 12:41:55 +00:00
likedQueryList = [ ] int { r . ID }
}
if user . Perms . EditReply && r . AttachCount > 0 {
2020-06-09 02:04:58 +00:00
if likedMap == nil {
attachMap = map [ int ] int { r . ID : 0 }
attachQueryList = [ ] int { r . ID }
} else {
attachMap = likedMap
attachQueryList = likedQueryList
}
2019-12-08 03:40:56 +00:00
}
2020-04-27 12:41:55 +00:00
2020-06-09 02:04:58 +00:00
H_topic_reply_row_assign_hook ( hTbl , r )
2020-04-27 12:41:55 +00:00
// TODO: Use a pointer instead to make it easier to abstract this loop? What impact would this have on escape analysis?
rlist = [ ] * ReplyUser { r }
//log.Printf("r: %d-%d", r.ID, len(rlist)-1)
2019-05-17 08:40:41 +00:00
} else {
2020-02-01 05:55:33 +00:00
//log.Print("reply query serve")
2020-08-15 02:37:56 +00:00
ap1 := func ( r * ReplyUser ) {
H_topic_reply_row_assign_hook ( hTbl , r )
// TODO: Use a pointer instead to make it easier to abstract this loop? What impact would this have on escape analysis?
rlist = append ( rlist , r )
//log.Printf("r: %d-%d", r.ID, len(rlist)-1)
}
2020-04-27 12:41:55 +00:00
rf2 := func ( r * ReplyUser ) {
if r . LikeCount > 0 && user . Liked > 0 {
if likedMap == nil {
likedMap = map [ int ] int { r . ID : len ( rlist ) }
likedQueryList = [ ] int { r . ID }
} else {
likedMap [ r . ID ] = len ( rlist )
likedQueryList = append ( likedQueryList , r . ID )
}
}
if user . Perms . EditReply && r . AttachCount > 0 {
if attachMap == nil {
attachMap = map [ int ] int { r . ID : len ( rlist ) }
attachQueryList = [ ] int { r . ID }
} else {
attachMap [ r . ID ] = len ( rlist )
attachQueryList = append ( attachQueryList , r . ID )
}
}
}
if ! user . Perms . ViewIPs && ruser != nil {
2020-08-15 02:37:56 +00:00
rows , e := topicStmts . getReplies3 . Query ( t . ID , offset , Config . ItemsPerPage )
2019-05-17 08:40:41 +00:00
if err != nil {
2020-08-15 02:37:56 +00:00
return nil , externalHead , e
2020-04-27 12:41:55 +00:00
}
defer rows . Close ( )
for rows . Next ( ) {
r := & ReplyUser { Avatar : ruser . Avatar , MicroAvatar : ruser . MicroAvatar , UserLink : ruser . Link , CreatedByName : ruser . Name , Group : ruser . Group , Level : ruser . Level }
2020-08-15 02:37:56 +00:00
e := rows . Scan ( & r . ID , & r . Content , & r . CreatedBy , & r . CreatedAt , & r . LastEdit , & r . LastEditBy , & r . LikeCount , & r . AttachCount , & r . ActionType )
if e != nil {
return nil , externalHead , e
2020-04-27 12:41:55 +00:00
}
2020-08-15 02:37:56 +00:00
if e = rf3 ( r ) ; e != nil {
return nil , externalHead , e
2020-04-27 12:41:55 +00:00
}
rf2 ( r )
2020-08-15 02:37:56 +00:00
ap1 ( r )
2019-05-17 08:40:41 +00:00
}
2020-08-15 02:37:56 +00:00
if e = rows . Err ( ) ; e != nil {
return nil , externalHead , e
2020-04-27 12:41:55 +00:00
}
} else if user . Perms . ViewIPs {
rows , err := topicStmts . getReplies . Query ( t . ID , offset , Config . ItemsPerPage )
2019-12-08 03:40:56 +00:00
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
defer rows . Close ( )
for rows . Next ( ) {
r := & ReplyUser { }
err := rows . Scan ( & r . ID , & r . Content , & r . CreatedBy , & r . CreatedAt , & r . LastEdit , & r . LastEditBy , & r . Avatar , & r . CreatedByName , & r . Group /*&r.URLPrefix, &r.URLName,*/ , & r . Level , & r . IP , & r . LikeCount , & r . AttachCount , & r . ActionType )
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
if err = rf ( r ) ; err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
rf2 ( r )
2020-08-15 02:37:56 +00:00
ap1 ( r )
2020-04-27 12:41:55 +00:00
}
if err = rows . Err ( ) ; err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
} else if t . PostCount >= 20 {
2020-08-15 02:37:56 +00:00
//log.Print("t.PostCount >= 20")
2020-04-27 12:41:55 +00:00
rows , err := topicStmts . getReplies3 . Query ( t . ID , offset , Config . ItemsPerPage )
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
defer rows . Close ( )
reqUserList := make ( map [ int ] bool )
for rows . Next ( ) {
r := & ReplyUser { }
err := rows . Scan ( & r . ID , & r . Content , & r . CreatedBy , & r . CreatedAt , & r . LastEdit , & r . LastEditBy /*&r.URLPrefix, &r.URLName,*/ , & r . LikeCount , & r . AttachCount , & r . ActionType )
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
if r . CreatedBy != t . CreatedBy && r . CreatedBy != user . ID {
reqUserList [ r . CreatedBy ] = true
}
2020-08-15 02:37:56 +00:00
ap1 ( r )
2020-04-27 12:41:55 +00:00
}
if err = rows . Err ( ) ; err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
2020-06-09 02:04:58 +00:00
if len ( reqUserList ) == 1 {
2020-08-15 02:37:56 +00:00
//log.Print("len(reqUserList) == 1: ", len(reqUserList) == 1)
2020-06-09 02:04:58 +00:00
var uitem * User
for uid , _ := range reqUserList {
uitem , err = Users . Get ( uid )
if err != nil {
return nil , externalHead , nil // TODO: Implement this!
}
2020-04-27 12:41:55 +00:00
}
2020-06-09 02:04:58 +00:00
for _ , r := range rlist {
if r . CreatedBy == t . CreatedBy {
r . CreatedByName = t . CreatedByName
r . Avatar = t . Avatar
r . MicroAvatar = t . MicroAvatar
r . Group = t . Group
r . Level = t . Level
} else {
var u * User
if r . CreatedBy == user . ID {
u = user
} else {
u = uitem
}
r . CreatedByName = u . Name
r . Avatar = u . Avatar
r . MicroAvatar = u . MicroAvatar
r . Group = u . Group
r . Level = u . Level
}
if err = rf ( r ) ; err != nil {
return nil , externalHead , err
}
rf2 ( r )
}
} else {
2020-08-15 02:37:56 +00:00
//log.Print("len(reqUserList) != 1: ", len(reqUserList) != 1)
2020-06-09 02:04:58 +00:00
var userList map [ int ] * User
if len ( reqUserList ) > 0 {
2020-08-15 02:37:56 +00:00
//log.Print("len(reqUserList) > 0: ", len(reqUserList) > 0)
2020-06-09 02:04:58 +00:00
// Convert the user ID map to a slice, then bulk load the users
idSlice := make ( [ ] int , len ( reqUserList ) )
var i int
for userID := range reqUserList {
idSlice [ i ] = userID
i ++
}
userList , err = Users . BulkGetMap ( idSlice )
if err != nil {
return nil , externalHead , nil // TODO: Implement this!
}
2020-04-27 12:41:55 +00:00
}
2020-06-09 02:04:58 +00:00
for _ , r := range rlist {
if r . CreatedBy == t . CreatedBy {
r . CreatedByName = t . CreatedByName
r . Avatar = t . Avatar
r . MicroAvatar = t . MicroAvatar
r . Group = t . Group
r . Level = t . Level
2020-04-27 12:41:55 +00:00
} else {
2020-06-09 02:04:58 +00:00
var u * User
if r . CreatedBy == user . ID {
u = user
} else {
u = userList [ r . CreatedBy ]
}
r . CreatedByName = u . Name
r . Avatar = u . Avatar
r . MicroAvatar = u . MicroAvatar
r . Group = u . Group
r . Level = u . Level
2020-04-27 12:41:55 +00:00
}
2020-06-09 02:04:58 +00:00
if err = rf ( r ) ; err != nil {
return nil , externalHead , err
}
rf2 ( r )
2020-04-27 12:41:55 +00:00
}
}
} else {
2020-08-15 02:37:56 +00:00
//log.Print("reply fallback")
2020-04-27 12:41:55 +00:00
rows , err := topicStmts . getReplies2 . Query ( t . ID , offset , Config . ItemsPerPage )
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
defer rows . Close ( )
for rows . Next ( ) {
r := & ReplyUser { }
err := rows . Scan ( & r . ID , & r . Content , & r . CreatedBy , & r . CreatedAt , & r . LastEdit , & r . LastEditBy , & r . Avatar , & r . CreatedByName , & r . Group /*&r.URLPrefix, &r.URLName,*/ , & r . Level , & r . LikeCount , & r . AttachCount , & r . ActionType )
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
if err = rf ( r ) ; err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2020-04-27 12:41:55 +00:00
}
rf2 ( r )
2020-08-15 02:37:56 +00:00
ap1 ( r )
2020-04-27 12:41:55 +00:00
}
if err = rows . Err ( ) ; err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2019-05-17 08:40:41 +00:00
}
}
}
// TODO: Add a config setting to disable the liked query for a burst of extra speed
2020-04-27 12:41:55 +00:00
if user . Liked > 0 && len ( likedQueryList ) > 0 /*&& user.LastLiked <= time.Now()*/ {
eids , err := Likes . BulkExists ( likedQueryList , user . ID , "replies" )
2019-05-17 08:40:41 +00:00
if err != nil {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2019-05-17 08:40:41 +00:00
}
2019-06-05 06:00:40 +00:00
for _ , eid := range eids {
rlist [ likedMap [ eid ] ] . Liked = true
}
2019-05-17 08:40:41 +00:00
}
if user . Perms . EditReply && len ( attachQueryList ) > 0 {
//log.Printf("attachQueryList: %+v\n", attachQueryList)
amap , err := Attachments . BulkMiniGetList ( "replies" , attachQueryList )
if err != nil && err != sql . ErrNoRows {
2020-06-09 02:04:58 +00:00
return nil , externalHead , err
2019-05-17 08:40:41 +00:00
}
//log.Printf("amap: %+v\n", amap)
//log.Printf("attachMap: %+v\n", attachMap)
for id , attach := range amap {
//log.Print("id:", id)
rlist [ attachMap [ id ] ] . Attachments = attach
/ * for _ , a := range attach {
log . Printf ( "a: %+v\n" , a )
} * /
}
}
2020-04-27 12:41:55 +00:00
//hTbl.VhookNoRet("topic_reply_end", &rlist)
2020-06-09 02:04:58 +00:00
return rlist , externalHead , nil
2019-05-17 08:40:41 +00:00
}
2019-04-08 07:44:41 +00:00
// TODO: Test this
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Author ( ) ( * User , error ) {
return Users . Get ( t . CreatedBy )
2019-04-08 07:44:41 +00:00
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) GetID ( ) int {
return t . ID
2018-01-27 07:30:44 +00:00
}
2019-08-31 22:34:43 +00:00
func ( t * Topic ) GetTable ( ) string {
2018-01-27 07:30:44 +00:00
return "topics"
}
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
// Copy gives you a non-pointer concurrency safe copy of the topic
2019-08-31 22:34:43 +00:00
func ( t * Topic ) Copy ( ) Topic {
return * t
2017-09-28 22:16:34 +00:00
}
2018-12-27 05:42:41 +00:00
// TODO: Load LastReplyAt and LastReplyID?
2018-01-20 06:50:29 +00:00
func TopicByReplyID ( rid int ) ( * Topic , error ) {
2019-08-31 22:34:43 +00:00
t := Topic { ID : 0 }
err := topicStmts . getByReplyID . QueryRow ( rid ) . Scan ( & t . ID , & t . Title , & t . Content , & t . CreatedBy , & t . CreatedAt , & t . IsClosed , & t . Sticky , & t . ParentID , & t . IP , & t . ViewCount , & t . PostCount , & t . LikeCount , & t . Poll , & t . Data )
t . Link = BuildTopicURL ( NameToSlug ( t . Title ) , t . ID )
return & t , err
2018-01-20 06:50:29 +00:00
}
2017-09-15 22:20:01 +00:00
// TODO: Refactor the caller to take a Topic and a User rather than a combined TopicUser
2018-06-24 13:49:29 +00:00
// TODO: Load LastReplyAt everywhere in here?
2018-11-22 07:21:43 +00:00
func GetTopicUser ( user * User , tid int ) ( tu TopicUser , err error ) {
2017-11-23 05:37:08 +00:00
tcache := Topics . GetCache ( )
ucache := Users . GetCache ( )
if tcache != nil && ucache != nil {
topic , err := tcache . Get ( tid )
2017-02-11 14:51:16 +00:00
if err == nil {
2018-11-22 07:21:43 +00:00
if topic . CreatedBy != user . ID {
user , err = Users . Get ( topic . CreatedBy )
if err != nil {
return TopicUser { ID : tid } , err
}
2017-02-11 14:51:16 +00:00
}
2017-10-30 09:57:08 +00:00
// We might be better off just passing separate topic and user structs to the caller?
2017-09-28 22:16:34 +00:00
return copyTopicToTopicUser ( topic , user ) , nil
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
} else if ucache . Length ( ) < ucache . GetCapacity ( ) {
2017-11-11 04:06:16 +00:00
topic , err = Topics . Get ( tid )
2017-02-11 14:51:16 +00:00
if err != nil {
2017-09-03 04:50:31 +00:00
return TopicUser { ID : tid } , err
2017-02-11 14:51:16 +00:00
}
2018-11-22 07:21:43 +00:00
if topic . CreatedBy != user . ID {
user , err = Users . Get ( topic . CreatedBy )
if err != nil {
return TopicUser { ID : tid } , err
}
2017-02-11 14:51:16 +00:00
}
2017-09-28 22:16:34 +00:00
return copyTopicToTopicUser ( topic , user ) , nil
2017-02-11 14:51:16 +00:00
}
}
2017-06-05 11:57:27 +00:00
2018-11-22 07:21:43 +00:00
tu = TopicUser { ID : tid }
2018-12-27 05:42:41 +00:00
// TODO: This misses some important bits...
2019-12-08 03:40:56 +00:00
err = topicStmts . getTopicUser . QueryRow ( tid ) . Scan ( & tu . Title , & tu . Content , & tu . CreatedBy , & tu . CreatedAt , & tu . LastReplyAt , & tu . LastReplyBy , & tu . LastReplyID , & tu . IsClosed , & tu . Sticky , & tu . ParentID , & tu . IP , & tu . ViewCount , & tu . PostCount , & tu . LikeCount , & tu . AttachCount , & tu . Poll , & tu . CreatedByName , & tu . Avatar , & tu . Group , & tu . Level )
2018-07-28 12:52:23 +00:00
tu . Avatar , tu . MicroAvatar = BuildAvatar ( tu . CreatedBy , tu . Avatar )
2017-11-11 04:06:16 +00:00
tu . Link = BuildTopicURL ( NameToSlug ( tu . Title ) , tu . ID )
tu . UserLink = BuildProfileURL ( NameToSlug ( tu . CreatedByName ) , tu . CreatedBy )
2017-11-23 05:37:08 +00:00
tu . Tag = Groups . DirtyGet ( tu . Group ) . Tag
2017-06-05 11:57:27 +00:00
2017-11-23 05:37:08 +00:00
if tcache != nil {
2021-01-02 21:46:24 +00:00
// TODO: weekly views
2019-08-31 22:34:43 +00:00
theTopic := Topic { ID : tu . ID , Link : tu . Link , Title : tu . Title , Content : tu . Content , CreatedBy : tu . CreatedBy , IsClosed : tu . IsClosed , Sticky : tu . Sticky , CreatedAt : tu . CreatedAt , LastReplyAt : tu . LastReplyAt , LastReplyID : tu . LastReplyID , ParentID : tu . ParentID , IP : tu . IP , ViewCount : tu . ViewCount , PostCount : tu . PostCount , LikeCount : tu . LikeCount , AttachCount : tu . AttachCount , Poll : tu . Poll }
2017-11-11 04:06:16 +00:00
//log.Printf("theTopic: %+v\n", theTopic)
2019-05-17 08:40:41 +00:00
_ = tcache . Set ( & theTopic )
2017-09-15 22:20:01 +00:00
}
2017-02-11 14:51:16 +00:00
return tu , err
}
2019-08-31 22:34:43 +00:00
func copyTopicToTopicUser ( t * Topic , u * User ) ( tu TopicUser ) {
tu . UserLink = u . Link
tu . CreatedByName = u . Name
tu . Group = u . Group
tu . Avatar = u . Avatar
tu . MicroAvatar = u . MicroAvatar
2019-12-08 03:40:56 +00:00
//tu.URLPrefix = u.URLPrefix
//tu.URLName = u.URLName
2019-08-31 22:34:43 +00:00
tu . Level = u . Level
tu . ID = t . ID
tu . Link = t . Link
tu . Title = t . Title
tu . Content = t . Content
tu . CreatedBy = t . CreatedBy
tu . IsClosed = t . IsClosed
tu . Sticky = t . Sticky
tu . CreatedAt = t . CreatedAt
tu . LastReplyAt = t . LastReplyAt
tu . LastReplyBy = t . LastReplyBy
tu . ParentID = t . ParentID
tu . IP = t . IP
tu . ViewCount = t . ViewCount
tu . PostCount = t . PostCount
tu . LikeCount = t . LikeCount
tu . AttachCount = t . AttachCount
tu . Poll = t . Poll
tu . Data = t . Data
tu . Rids = t . Rids
2017-06-28 12:05:26 +00:00
2017-02-11 14:51:16 +00:00
return tu
2017-02-28 09:27:28 +00:00
}
2017-09-28 22:16:34 +00:00
// For use in tests and for generating blank topics for forums which don't have a last poster
2017-11-11 04:06:16 +00:00
func BlankTopic ( ) * Topic {
2018-06-06 06:13:55 +00:00
return new ( Topic )
2017-09-28 22:16:34 +00:00
}
2017-11-11 04:06:16 +00:00
func BuildTopicURL ( slug string , tid int ) string {
2018-04-03 04:34:07 +00:00
if slug == "" || ! Config . BuildSlugs {
2017-06-28 12:05:26 +00:00
return "/topic/" + strconv . Itoa ( tid )
}
return "/topic/" + slug + "." + strconv . Itoa ( tid )
2017-02-28 09:27:28 +00:00
}
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
2020-04-27 12:41:55 +00:00
func BuildTopicURLSb ( sb * strings . Builder , slug string , tid int ) {
if slug == "" || ! Config . BuildSlugs {
sb . Grow ( 7 + 2 )
sb . WriteString ( "/topic/" )
sb . WriteString ( strconv . Itoa ( tid ) )
return
}
sb . Grow ( 7 + 3 + len ( slug ) )
sb . WriteString ( "/topic/" )
sb . WriteString ( slug )
sb . WriteRune ( '.' )
sb . WriteString ( strconv . Itoa ( tid ) )
}
2017-09-03 04:50:31 +00:00
// I don't care if it isn't used,, it will likely be in the future. Nolint.
// nolint
func getTopicURLPrefix ( ) string {
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
return "/topic/"
}