Fix some small things

pull/31/head
Jan-Lukas Else 2 months ago
parent ea0f1bfe05
commit 38e8ac934f
  1. 16
      .golangci.yml
  2. 6
      activityPub.go
  3. 10
      activityStreams.go
  4. 4
      database.go
  5. 2
      postsDb.go

@ -14,22 +14,24 @@ linters:
- gosimple
- govet
- ineffassign
- structcheck
- staticcheck
- typecheck
- unused
- varcheck
# Other linters
- asasalint
- bidichk
- bodyclose
- containedctx
- contextcheck
- dupl
- durationcheck
- gofmt
- bodyclose
- gosec
- makezero
- noctx
- prealloc
- unparam
- durationcheck
- bidichk
- containedctx
- contextcheck
- gosec
linters-settings:
gosimple:
go: "1.19"

@ -404,11 +404,7 @@ func (a *goBlog) apAccept(blogName string, blog *configBlog, follow map[string]a
func (a *goBlog) apSendProfileUpdates() {
for blog, config := range a.cfg.Blogs {
person, err := a.toAsPerson(blog)
if err != nil {
log.Println("Failed to create Person object:", err)
continue
}
person := a.toAsPerson(blog)
a.apSendToAllFollowers(blog, map[string]any{
"@context": []string{asContext},
"actor": a.apIri(config),

@ -167,7 +167,7 @@ func (a *goBlog) activityPubId(p *post) string {
return fu
}
func (a *goBlog) toAsPerson(blog string) (*asPerson, error) {
func (a *goBlog) toAsPerson(blog string) *asPerson {
b := a.cfg.Blogs[blog]
asBlog := &asPerson{
Context: []string{asContext},
@ -194,15 +194,11 @@ func (a *goBlog) toAsPerson(blog string) (*asPerson, error) {
URL: a.cfg.User.Picture,
}
}
return asBlog, nil
return asBlog
}
func (a *goBlog) serveActivityStreams(blog string, w http.ResponseWriter, r *http.Request) {
person, err := a.toAsPerson(blog)
if err != nil {
a.serveError(w, r, "Failed to create ActivityStreams Person", http.StatusInternalServerError)
return
}
person := a.toAsPerson(blog)
// Encode
buf := bufferpool.Get()
defer bufferpool.Put(buf)

@ -103,14 +103,14 @@ func (a *goBlog) openDatabase(file string, logging bool) (*database, error) {
if err != nil {
return nil, err
}
cos := map[string]bool{}
cos := map[string]struct{}{}
var co string
for rows.Next() {
err = rows.Scan(&co)
if err != nil {
return nil, err
}
cos[co] = true
cos[co] = struct{}{}
}
if _, ok := cos["ENABLE_FTS5"]; !ok {
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) {
var values []string
// 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))
if err != nil {
return nil, err
}
var values []string
var value string
for rows.Next() {
if err = rows.Scan(&value); err != nil {

Loading…
Cancel
Save