mirror of https://github.com/jlelse/GoBlog
Fix some small things
This commit is contained in:
parent
ea0f1bfe05
commit
38e8ac934f
|
@ -14,22 +14,24 @@ linters:
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- structcheck
|
- staticcheck
|
||||||
- typecheck
|
- typecheck
|
||||||
- unused
|
- unused
|
||||||
- varcheck
|
- varcheck
|
||||||
# Other linters
|
# Other linters
|
||||||
- dupl
|
- asasalint
|
||||||
- gofmt
|
- bidichk
|
||||||
- bodyclose
|
- bodyclose
|
||||||
|
- containedctx
|
||||||
|
- contextcheck
|
||||||
|
- dupl
|
||||||
|
- durationcheck
|
||||||
|
- gofmt
|
||||||
|
- gosec
|
||||||
|
- makezero
|
||||||
- noctx
|
- noctx
|
||||||
- prealloc
|
- prealloc
|
||||||
- unparam
|
- unparam
|
||||||
- durationcheck
|
|
||||||
- bidichk
|
|
||||||
- containedctx
|
|
||||||
- contextcheck
|
|
||||||
- gosec
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
gosimple:
|
gosimple:
|
||||||
go: "1.19"
|
go: "1.19"
|
||||||
|
|
|
@ -404,11 +404,7 @@ func (a *goBlog) apAccept(blogName string, blog *configBlog, follow map[string]a
|
||||||
|
|
||||||
func (a *goBlog) apSendProfileUpdates() {
|
func (a *goBlog) apSendProfileUpdates() {
|
||||||
for blog, config := range a.cfg.Blogs {
|
for blog, config := range a.cfg.Blogs {
|
||||||
person, err := a.toAsPerson(blog)
|
person := a.toAsPerson(blog)
|
||||||
if err != nil {
|
|
||||||
log.Println("Failed to create Person object:", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
a.apSendToAllFollowers(blog, map[string]any{
|
a.apSendToAllFollowers(blog, map[string]any{
|
||||||
"@context": []string{asContext},
|
"@context": []string{asContext},
|
||||||
"actor": a.apIri(config),
|
"actor": a.apIri(config),
|
||||||
|
|
|
@ -167,7 +167,7 @@ func (a *goBlog) activityPubId(p *post) string {
|
||||||
return fu
|
return fu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *goBlog) toAsPerson(blog string) (*asPerson, error) {
|
func (a *goBlog) toAsPerson(blog string) *asPerson {
|
||||||
b := a.cfg.Blogs[blog]
|
b := a.cfg.Blogs[blog]
|
||||||
asBlog := &asPerson{
|
asBlog := &asPerson{
|
||||||
Context: []string{asContext},
|
Context: []string{asContext},
|
||||||
|
@ -194,15 +194,11 @@ func (a *goBlog) toAsPerson(blog string) (*asPerson, error) {
|
||||||
URL: a.cfg.User.Picture,
|
URL: a.cfg.User.Picture,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return asBlog, nil
|
return asBlog
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *goBlog) serveActivityStreams(blog string, w http.ResponseWriter, r *http.Request) {
|
func (a *goBlog) serveActivityStreams(blog string, w http.ResponseWriter, r *http.Request) {
|
||||||
person, err := a.toAsPerson(blog)
|
person := a.toAsPerson(blog)
|
||||||
if err != nil {
|
|
||||||
a.serveError(w, r, "Failed to create ActivityStreams Person", http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Encode
|
// Encode
|
||||||
buf := bufferpool.Get()
|
buf := bufferpool.Get()
|
||||||
defer bufferpool.Put(buf)
|
defer bufferpool.Put(buf)
|
||||||
|
|
|
@ -103,14 +103,14 @@ func (a *goBlog) openDatabase(file string, logging bool) (*database, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cos := map[string]bool{}
|
cos := map[string]struct{}{}
|
||||||
var co string
|
var co string
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err = rows.Scan(&co)
|
err = rows.Scan(&co)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cos[co] = true
|
cos[co] = struct{}{}
|
||||||
}
|
}
|
||||||
if _, ok := cos["ENABLE_FTS5"]; !ok {
|
if _, ok := cos["ENABLE_FTS5"]; !ok {
|
||||||
return nil, errors.New("sqlite not compiled with FTS5")
|
return nil, errors.New("sqlite not compiled with FTS5")
|
||||||
|
|
|
@ -620,12 +620,12 @@ func (a *goBlog) getRandomPostPath(blog string) (path string, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *database) allTaxonomyValues(blog string, taxonomy string) ([]string, error) {
|
func (d *database) allTaxonomyValues(blog string, taxonomy string) ([]string, error) {
|
||||||
var values []string
|
|
||||||
// TODO: Query posts the normal way
|
// TODO: Query posts the normal way
|
||||||
rows, err := d.query("select distinct value from post_parameters where parameter = @tax and length(coalesce(value, '')) > 0 and path in (select path from posts where blog = @blog and status = @status) order by value", sql.Named("tax", taxonomy), sql.Named("blog", blog), sql.Named("status", statusPublished))
|
rows, err := d.query("select distinct value from post_parameters where parameter = @tax and length(coalesce(value, '')) > 0 and path in (select path from posts where blog = @blog and status = @status) order by value", sql.Named("tax", taxonomy), sql.Named("blog", blog), sql.Named("status", statusPublished))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
var values []string
|
||||||
var value string
|
var value string
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
if err = rows.Scan(&value); err != nil {
|
if err = rows.Scan(&value); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue