Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions internal/dnsdb/dnsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"
"time"

"github.com/miekg/dns"

"github.com/nt0xa/sonar/internal/database"
"github.com/nt0xa/sonar/internal/utils/pointer"
"github.com/nt0xa/sonar/internal/utils/slice"
"github.com/nt0xa/sonar/pkg/dnsx"
)

Expand Down Expand Up @@ -110,7 +109,7 @@ func (h *Records) Get(ctx context.Context, name string, qtype uint16) ([]dns.RR,
record.LastAccessedAt != nil &&
len(record.LastAnswer) > 0 &&
time.Since(*record.LastAccessedAt) < time.Second*3 {
i := slice.FindIndex(record.Values, record.LastAnswer[0])
i := slices.Index(record.Values, record.LastAnswer[0])
res = []dns.RR{rrs[min(i+1, len(rrs)-1)]}
} else {
// Fallback to first record.
Expand All @@ -120,7 +119,7 @@ func (h *Records) Get(ctx context.Context, name string, qtype uint16) ([]dns.RR,

// Update last answer and last answer time.
lastAnswer := dnsx.RRsToStrings(res)
lastAccessedAt := pointer.Time(time.Now())
lastAccessedAt := time.Now()

if _, err := h.DB.DNSRecordsUpdate(ctx, database.DNSRecordsUpdateParams{
ID: record.ID,
Expand All @@ -131,7 +130,7 @@ func (h *Records) Get(ctx context.Context, name string, qtype uint16) ([]dns.RR,
Values: record.Values,
Strategy: record.Strategy,
LastAnswer: lastAnswer,
LastAccessedAt: lastAccessedAt,
LastAccessedAt: &lastAccessedAt,
}); err != nil {
return nil, err
}
Expand Down
25 changes: 0 additions & 25 deletions internal/modules/lark/context.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/modules/lark/lark.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ func (lrk *Lark) makeDispatcher(verificationToken, eventEncryptKey string, dedup
return nil
}

ctx = SetMessageID(ctx, *msgID)

text := msg.Text

// remove @mention from the text
Expand Down
3 changes: 1 addition & 2 deletions internal/modules/telegram/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/nt0xa/sonar/internal/database"
"github.com/nt0xa/sonar/internal/service"
"github.com/nt0xa/sonar/internal/templates"
"github.com/nt0xa/sonar/internal/utils/errors"
"github.com/nt0xa/sonar/pkg/telemetry"
)

Expand Down Expand Up @@ -117,7 +116,7 @@ func (tg *Telegram) preExec(root *cobra.Command) {
RunE: func(cmd *cobra.Command, args []string) error {
mi, err := getMsgInfo(cmd.Context())
if err != nil {
return errors.Internal(err)
return err
}

tg.htmlMessage(cmd.Context(), mi.chatID, &mi.msgID, fmt.Sprintf("<code>%d</code>", mi.chatID))
Expand Down
219 changes: 0 additions & 219 deletions internal/utils/errors/errors.go

This file was deleted.

50 changes: 0 additions & 50 deletions internal/utils/parse/json.go

This file was deleted.

19 changes: 0 additions & 19 deletions internal/utils/pointer/pointer.go

This file was deleted.

Loading
Loading