top page now displays published posts
This commit is contained in:
@@ -112,6 +112,28 @@ func (c *Conference) Hosts(ctx context.Context) ([]*User, error) {
|
||||
return rc, nil
|
||||
}
|
||||
|
||||
// ContainedBy returns the communities that contain this conference.
|
||||
func (c *Conference) ContainedBy(ctx context.Context) ([]*Community, error) {
|
||||
rs, err := amdb.QueryContext(ctx, "SELECT commid FROM commtoconf WHERE confid = ?", c.ConfId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rc := make([]*Community, 0, 1)
|
||||
for rs.Next() {
|
||||
var cid int32
|
||||
if err = rs.Scan(&cid); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
comm, err := AmGetCommunity(ctx, cid)
|
||||
if err == nil {
|
||||
rc = append(rc, comm)
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return rc, nil
|
||||
}
|
||||
|
||||
// Hosts returns the list of users that host this conference, quietly.
|
||||
func (c *Conference) HostsQ(ctx context.Context) []*User {
|
||||
rc, _ := c.Hosts(ctx)
|
||||
@@ -176,6 +198,25 @@ func (c *Conference) Settings(ctx context.Context, u *User) (*ConferenceSettings
|
||||
return &(dbdata[0]), nil
|
||||
}
|
||||
|
||||
// Link returns a link string to this conference.
|
||||
func (c *Conference) Link(ctx context.Context, scope string) (string, error) {
|
||||
aliases, err := c.Aliases(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if scope == "community" {
|
||||
return fmt.Sprintf("%s.", aliases[0]), nil
|
||||
}
|
||||
if scope == "global" {
|
||||
comms, err := c.ContainedBy(ctx)
|
||||
if err == nil {
|
||||
return fmt.Sprintf("%s!%s", comms[0].Alias, aliases[0]), nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return "", errors.New("invalid scope")
|
||||
}
|
||||
|
||||
// DefaultPseud returns the default pseud for a user in the conference.
|
||||
func (c *Conference) DefaultPseud(ctx context.Context, u *User) (string, error) {
|
||||
settings, err := c.Settings(ctx, u)
|
||||
|
||||
Reference in New Issue
Block a user