set up show/hide of controls on topic page
This commit is contained in:
@@ -44,6 +44,20 @@ func (p *PostHeader) IsScribbled() bool {
|
||||
return p.ScribbleUid != nil && p.ScribbleDate != nil
|
||||
}
|
||||
|
||||
// IsPublished returns true if the post has been published to the front page.
|
||||
func (p *PostHeader) IsPublished(ctx context.Context) (bool, error) {
|
||||
rs, err := amdb.QueryContext(ctx, "SELECT COUNT(*) FROM postpublish WHERE postid = ?", p.PostId)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !rs.Next() {
|
||||
return false, errors.New("internal failure in IsPublished")
|
||||
}
|
||||
ct := 0
|
||||
err = rs.Scan(&ct)
|
||||
return ct > 0, err
|
||||
}
|
||||
|
||||
/* SetAttachment sets the attachment data for a post.
|
||||
* Parameters:
|
||||
* ctx - Standard Go context value.
|
||||
|
||||
@@ -81,6 +81,19 @@ func (t *Topic) SetLastRead(ctx context.Context, u *User, postNum int32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// IsHidden tells us whether the user has the topic hidden.
|
||||
func (t *Topic) IsHidden(ctx context.Context, u *User) (bool, error) {
|
||||
rs, err := amdb.QueryContext(ctx, "SELECT hidden FROM topicsettings WHERE topicid = ? AND uid = ?", t.TopicId, u.Uid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
rc := false
|
||||
if rs.Next() {
|
||||
err = rs.Scan(&rc)
|
||||
}
|
||||
return rc, err
|
||||
}
|
||||
|
||||
// TopicSettings contains per-user settings for topics, including the "last read" message pointer.
|
||||
type TopicSettings struct {
|
||||
TopicId int32 `db:"topicid"` // unique ID of the topic
|
||||
|
||||
Reference in New Issue
Block a user