Skip to content

Commit

Permalink
Deps update:
Browse files Browse the repository at this point in the history
- dgraph-io/badger/v4 to v4.0.1

When sending HTTP requests, make sure to also send Cache-Control :
no-cache and Pragma: no-cache

Update deps for contrib random_delete_test.
  • Loading branch information
dkorunic committed Mar 7, 2023
1 parent 3bfe802 commit 8cd7f45
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 104 deletions.
12 changes: 6 additions & 6 deletions contrib/random_delete_test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/dkorunic/e-dnevnik-bot/contrib
go 1.20

require (
filippo.io/mostly-harmless/cryptosource v0.0.0-20230118130925-0e48fbe82492
github.com/dgraph-io/badger/v3 v3.2103.5
filippo.io/mostly-harmless/cryptosource v0.0.0-20230306161022-15e20eab989c
github.com/dgraph-io/badger/v4 v4.0.1
)

require (
Expand All @@ -13,15 +13,15 @@ require (
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers/go v0.0.0-20230110200425-62e4d2e5b215 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
)
64 changes: 12 additions & 52 deletions contrib/random_delete_test/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contrib/random_delete_test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"filippo.io/mostly-harmless/cryptosource"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/dkorunic/e-dnevnik-bot/logger"

"github.com/dgraph-io/badger/v3"
"github.com/dgraph-io/badger/v4"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (c *Client) Login() error {
// GetClassEvents attempts to fetch all subjects and their grades, as well as all calendar events for exams in ICS
// format, returning raw grades listing body, parsed exam events and optional error.
func (c *Client) GetClassEvents(classID string) (string, Events, error) {
// do class action to switch active class
// do class action to switch active class to class ID
err := c.doClassAction(classID)
if err != nil {
return "", Events{}, err
Expand All @@ -101,7 +101,7 @@ func (c *Client) GetClassEvents(classID string) (string, Events, error) {
// GetClasses attempts to fetch all courses where a student has been previously enlisted or still is (multiple
// active classes possible).
func (c *Client) GetClasses() (string, error) {
// fetch all classes
// fetch all active classes
rawClasses, err := c.getClasses()
if err != nil {
return "", err
Expand Down
12 changes: 12 additions & 0 deletions fetch/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func (c *Client) getCSRFToken() error {
return err
}
req.Header.Set("User-Agent", c.userAgent)
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")

resp, err := c.httpClient.Do(req)
if err != nil {
Expand Down Expand Up @@ -105,6 +107,8 @@ func (c *Client) doSAMLRequest() error {
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("User-Agent", c.userAgent)
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")
req.Header.Set("Referer", LoginURL)

resp, err := c.httpClient.Do(req)
Expand Down Expand Up @@ -141,6 +145,8 @@ func (c *Client) getGrades() (string, error) {
return "", err
}
req.Header.Set("User-Agent", c.userAgent)
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")
req.Header.Set("Referer", LoginURL)

resp, err := c.httpClient.Do(req)
Expand Down Expand Up @@ -178,6 +184,8 @@ func (c *Client) getCalendar() (Events, error) {
return Events{}, err
}
req.Header.Set("User-Agent", c.userAgent)
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")
req.Header.Set("Referer", LoginURL)

resp, err := c.httpClient.Do(req)
Expand Down Expand Up @@ -222,6 +230,8 @@ func (c *Client) getClasses() (string, error) {
return "", err
}
req.Header.Set("User-Agent", c.userAgent)
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")
req.Header.Set("Referer", LoginURL)

resp, err := c.httpClient.Do(req)
Expand Down Expand Up @@ -258,6 +268,8 @@ func (c *Client) doClassAction(classID string) error {
return err
}
req.Header.Set("User-Agent", c.userAgent)
req.Header.Set("Cache-Control", "no-cache")
req.Header.Set("Pragma", "no-cache")
req.Header.Set("Referer", LoginURL)

resp, err := c.httpClient.Do(req)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/avast/retry-go/v4 v4.3.3
github.com/bwmarrin/discordgo v0.27.0
github.com/corpix/uarand v0.2.0
github.com/dgraph-io/badger/v3 v3.2103.5
github.com/dgraph-io/badger/v4 v4.0.1
github.com/dustin/go-broadcast v0.0.0-20211018055107-71439988bd91
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
github.com/jordic/goics v0.0.0-20210404174824-5a0337b716a0
Expand Down
Loading

0 comments on commit 8cd7f45

Please sign in to comment.