2017-09-13 15:09:13 +00:00
/ *
*
* Gosora Topic Store
2018-09-13 07:41:01 +00:00
* Copyright Azareal 2017 - 2019
2017-09-13 15:09:13 +00:00
*
* /
2017-11-10 03:33:11 +00:00
package common
2017-06-13 07:12:58 +00:00
2017-09-15 22:20:01 +00:00
import (
"database/sql"
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
"errors"
"strings"
2017-09-15 22:20:01 +00:00
2018-10-27 03:21:02 +00:00
"github.com/Azareal/Gosora/query_gen"
2017-09-15 22:20:01 +00:00
)
2017-06-13 07:12:58 +00:00
2017-09-10 16:57:22 +00:00
// TODO: Add the watchdog goroutine
2017-09-15 22:20:01 +00:00
// TODO: Add BulkGetMap
// TODO: Add some sort of update method
2017-09-18 17:03:52 +00:00
// ? - Should we add stick, lock, unstick, and unlock methods? These might be better on the Topics not the TopicStore
2017-11-11 04:06:16 +00:00
var Topics TopicStore
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
var ErrNoTitle = errors . New ( "This message is missing a title" )
2018-03-17 08:16:43 +00:00
var ErrLongTitle = errors . New ( "The title is too long" )
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
var ErrNoBody = errors . New ( "This message is missing a body" )
2017-06-13 07:12:58 +00:00
type TopicStore interface {
2017-11-11 04:06:16 +00:00
DirtyGet ( id int ) * Topic
2017-06-13 07:12:58 +00:00
Get ( id int ) ( * Topic , error )
BypassGet ( id int ) ( * Topic , error )
2017-09-15 22:20:01 +00:00
Exists ( id int ) bool
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
Create ( fid int , topicName string , content string , uid int , ipaddress string ) ( tid int , err error )
2017-09-18 17:03:52 +00:00
AddLastTopic ( item * Topic , fid int ) error // unimplemented
2017-11-23 05:37:08 +00:00
Reload ( id int ) error // Too much SQL logic to move into TopicCache
2017-09-18 17:03:52 +00:00
// TODO: Implement these two methods
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
//Replies(tid int) ([]*Reply, error)
//RepliesRange(tid int, lower int, higher int) ([]*Reply, error)
GlobalCount ( ) int
2017-09-15 22:20:01 +00:00
2017-11-23 05:37:08 +00:00
SetCache ( cache TopicCache )
GetCache ( ) TopicCache
2017-06-13 07:12:58 +00:00
}
2017-11-23 05:37:08 +00:00
type DefaultTopicStore struct {
cache TopicCache
2017-09-15 22:20:01 +00:00
get * sql . Stmt
exists * sql . Stmt
topicCount * sql . Stmt
2017-11-07 22:38:15 +00:00
create * sql . Stmt
2017-06-13 07:12:58 +00:00
}
2017-11-23 05:37:08 +00:00
// NewDefaultTopicStore gives you a new instance of DefaultTopicStore
func NewDefaultTopicStore ( cache TopicCache ) ( * DefaultTopicStore , error ) {
2018-08-04 11:46:36 +00:00
acc := qgen . NewAcc ( )
2017-11-23 05:37:08 +00:00
if cache == nil {
cache = NewNullTopicCache ( )
}
return & DefaultTopicStore {
cache : cache ,
2018-12-27 05:42:41 +00:00
get : acc . Select ( "topics" ) . Columns ( "title, content, createdBy, createdAt, lastReplyAt, lastReplyID, is_closed, sticky, parentID, ipaddress, views, postCount, likeCount, attachCount, poll, data" ) . Where ( "tid = ?" ) . Prepare ( ) ,
2017-11-12 03:29:05 +00:00
exists : acc . Select ( "topics" ) . Columns ( "tid" ) . Where ( "tid = ?" ) . Prepare ( ) ,
topicCount : acc . Count ( "topics" ) . Prepare ( ) ,
create : acc . Insert ( "topics" ) . Columns ( "parentID, title, content, parsed_content, createdAt, lastReplyAt, lastReplyBy, ipaddress, words, createdBy" ) . Fields ( "?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,?" ) . Prepare ( ) ,
2017-11-06 07:23:32 +00:00
} , acc . FirstError ( )
2017-06-13 07:12:58 +00:00
}
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) DirtyGet ( id int ) * Topic {
topic , err := mts . cache . Get ( id )
if err == nil {
2017-11-11 04:06:16 +00:00
return topic
}
topic = & Topic { ID : id }
2018-12-27 05:42:41 +00:00
err = mts . get . QueryRow ( id ) . Scan ( & topic . Title , & topic . Content , & topic . CreatedBy , & topic . CreatedAt , & topic . LastReplyAt , & topic . LastReplyID , & topic . IsClosed , & topic . Sticky , & topic . ParentID , & topic . IPAddress , & topic . ViewCount , & topic . PostCount , & topic . LikeCount , & topic . AttachCount , & topic . Poll , & topic . Data )
2017-11-11 04:06:16 +00:00
if err == nil {
topic . Link = BuildTopicURL ( NameToSlug ( topic . Title ) , id )
2017-11-23 05:37:08 +00:00
_ = mts . cache . Add ( topic )
2017-11-11 04:06:16 +00:00
return topic
}
return BlankTopic ( )
}
2017-11-23 05:37:08 +00:00
// TODO: Log weird cache errors?
func ( mts * DefaultTopicStore ) Get ( id int ) ( topic * Topic , err error ) {
topic , err = mts . cache . Get ( id )
if err == nil {
2017-06-13 07:12:58 +00:00
return topic , nil
}
2017-09-03 04:50:31 +00:00
topic = & Topic { ID : id }
2018-12-27 05:42:41 +00:00
err = mts . get . QueryRow ( id ) . Scan ( & topic . Title , & topic . Content , & topic . CreatedBy , & topic . CreatedAt , & topic . LastReplyAt , & topic . LastReplyID , & topic . IsClosed , & topic . Sticky , & topic . ParentID , & topic . IPAddress , & topic . ViewCount , & topic . PostCount , & topic . LikeCount , & topic . AttachCount , & topic . Poll , & topic . Data )
2017-06-13 07:12:58 +00:00
if err == nil {
2017-11-11 04:06:16 +00:00
topic . Link = BuildTopicURL ( NameToSlug ( topic . Title ) , id )
2017-11-23 05:37:08 +00:00
_ = mts . cache . Add ( topic )
2017-06-13 07:12:58 +00:00
}
return topic , err
}
2017-09-18 17:03:52 +00:00
// BypassGet will always bypass the cache and pull the topic directly from the database
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) BypassGet ( id int ) ( * Topic , error ) {
2017-09-03 04:50:31 +00:00
topic := & Topic { ID : id }
2018-12-27 05:42:41 +00:00
err := mts . get . QueryRow ( id ) . Scan ( & topic . Title , & topic . Content , & topic . CreatedBy , & topic . CreatedAt , & topic . LastReplyAt , & topic . LastReplyID , & topic . IsClosed , & topic . Sticky , & topic . ParentID , & topic . IPAddress , & topic . ViewCount , & topic . PostCount , & topic . LikeCount , & topic . AttachCount , & topic . Poll , & topic . Data )
2017-11-11 04:06:16 +00:00
topic . Link = BuildTopicURL ( NameToSlug ( topic . Title ) , id )
2017-06-13 07:12:58 +00:00
return topic , err
}
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) Reload ( id int ) error {
2017-09-03 04:50:31 +00:00
topic := & Topic { ID : id }
2018-12-27 05:42:41 +00:00
err := mts . get . QueryRow ( id ) . Scan ( & topic . Title , & topic . Content , & topic . CreatedBy , & topic . CreatedAt , & topic . LastReplyAt , & topic . LastReplyID , & topic . IsClosed , & topic . Sticky , & topic . ParentID , & topic . IPAddress , & topic . ViewCount , & topic . PostCount , & topic . LikeCount , & topic . AttachCount , & topic . Poll , & topic . Data )
2017-06-13 07:12:58 +00:00
if err == nil {
2017-11-11 04:06:16 +00:00
topic . Link = BuildTopicURL ( NameToSlug ( topic . Title ) , id )
2017-11-23 05:37:08 +00:00
_ = mts . cache . Set ( topic )
2017-06-13 07:12:58 +00:00
} else {
2017-11-23 05:37:08 +00:00
_ = mts . cache . Remove ( id )
2017-06-13 07:12:58 +00:00
}
2018-11-19 23:06:15 +00:00
TopicListThaw . Thaw ( )
2017-06-13 07:12:58 +00:00
return err
}
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) Exists ( id int ) bool {
2017-09-18 17:03:52 +00:00
return mts . exists . QueryRow ( id ) . Scan ( & id ) == nil
2017-09-15 22:20:01 +00:00
}
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) Create ( fid int , topicName string , content string , uid int , ipaddress string ) ( tid int , err error ) {
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
if topicName == "" {
2018-03-17 08:16:43 +00:00
return 0 , 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 ( topicName ) > Config . MaxTopicTitleLength {
return 0 , ErrLongTitle
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
}
2018-05-31 06:51:31 +00:00
parsedContent := strings . TrimSpace ( ParseMessage ( content , fid , "forums" ) )
if parsedContent == "" {
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
return 0 , ErrNoBody
}
2017-11-11 04:06:16 +00:00
wcount := WordCount ( content )
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
// TODO: Move this statement into the topic store
2017-11-07 22:38:15 +00:00
res , err := mts . create . Exec ( fid , topicName , content , parsedContent , uid , ipaddress , wcount , uid )
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
if err != nil {
return 0 , err
}
lastID , err := res . LastInsertId ( )
if err != nil {
return 0 , err
}
2017-11-23 05:37:08 +00:00
return int ( lastID ) , Forums . AddTopic ( int ( lastID ) , uid , fid )
2017-06-13 07:12:58 +00:00
}
2017-09-15 22:20:01 +00:00
// ? - What is this? Do we need it? Should it be in the main store interface?
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) AddLastTopic ( item * Topic , fid int ) error {
2017-06-13 07:12:58 +00:00
// Coming Soon...
return 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
// GlobalCount returns the total number of topics on these forums
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) GlobalCount ( ) ( tcount int ) {
2017-09-18 17:03:52 +00:00
err := mts . topicCount . QueryRow ( ) . Scan ( & tcount )
2017-09-15 22:20:01 +00:00
if err != nil {
LogError ( err )
}
return tcount
}
2017-11-23 05:37:08 +00:00
func ( mts * DefaultTopicStore ) SetCache ( cache TopicCache ) {
mts . cache = cache
2017-06-13 07:12:58 +00:00
}
2017-11-23 05:37:08 +00:00
// TODO: We're temporarily doing this so that you can do tcache != nil in getTopicUser. Refactor it.
func ( mts * DefaultTopicStore ) GetCache ( ) TopicCache {
_ , ok := mts . cache . ( * NullTopicCache )
if ok {
return nil
2017-09-15 22:20:01 +00:00
}
2017-11-23 05:37:08 +00:00
return mts . cache
2017-06-13 07:12:58 +00:00
}