Skip to content

Commit

Permalink
changes variable name from retrieve to isBlocked
Browse files Browse the repository at this point in the history
  • Loading branch information
mflilian committed Apr 12, 2022
1 parent 5bcda97 commit a551eaf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func TestHistoryHandler(t *testing.T) {
err = InsertMongoMessagesWithParameters(ctx, []string{topic}, true)
Expect(err).To(BeNil())

path := fmt.Sprintf("/history/%s?userid=%s&limit=1000&retrieve=true", topic, userID)
path := fmt.Sprintf("/history/%s?userid=%s&limit=1000&isBlocked=true", topic, userID)
status, body := Get(a, path, t)
g.Assert(status).Equal(http.StatusOK)

Expand Down
4 changes: 2 additions & 2 deletions app/history_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func HistoryV2Handler(app *App) func(c echo.Context) error {
return func(c echo.Context) error {
c.Set("route", "HistoryV2")
topic := c.ParamValues()[0]
userID, from, limit, retrieve := ParseHistoryQueryParams(c, app.Defaults.LimitOfMessages)
userID, from, limit, isBlocked := ParseHistoryQueryParams(c, app.Defaults.LimitOfMessages)
authenticated, _, err := IsAuthorized(c.StdContext(), app, userID, topic)
if err != nil {
return err
Expand All @@ -33,7 +33,7 @@ func HistoryV2Handler(app *App) func(c echo.Context) error {

messages := make([]*models.MessageV2, 0)
collection := app.Defaults.MongoMessagesCollection
messages = mongoclient.GetMessagesV2WithParameter(c, topic, from, limit, collection, retrieve)
messages = mongoclient.GetMessagesV2WithParameter(c, topic, from, limit, collection, isBlocked)

return c.JSON(http.StatusOK, messages)
}
Expand Down
2 changes: 1 addition & 1 deletion app/history_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestHistoryV2Handler(t *testing.T) {
err = InsertMongoMessagesWithParameters(ctx, []string{topic}, true)
Expect(err).To(BeNil())

path := fmt.Sprintf("/v2/history/%s?userid=%s&limit=1000&retrieve=true", topic, userID)
path := fmt.Sprintf("/v2/history/%s?userid=%s&limit=1000&isBlocked=true", topic, userID)
status, body := Get(a, path, t)
g.Assert(status).Equal(http.StatusOK)

Expand Down
4 changes: 2 additions & 2 deletions app/query_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func ParseHistoryQueryParams(c echo.Context, defaultLimit int64) (string, int64,
userID := c.QueryParam("userid")
from, _ := strconv.ParseInt(c.QueryParam("from"), 10, 64)
limit, _ := strconv.ParseInt(c.QueryParam("limit"), 10, 64)
retrieve, _ := strconv.ParseBool(c.QueryParam("retrieve"))
isBlocked, _ := strconv.ParseBool(c.QueryParam("isBlocked"))

if limit == 0 {
limit = defaultLimit
Expand All @@ -22,7 +22,7 @@ func ParseHistoryQueryParams(c echo.Context, defaultLimit int64) (string, int64,
from = time.Now().Unix()
}

return userID, from, limit, retrieve
return userID, from, limit, isBlocked
}

func ParseHistoriesQueryParams(c echo.Context, defaultLimit int64) ([]string, string, int64, int64) {
Expand Down
4 changes: 2 additions & 2 deletions mongoclient/get_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func GetMessagesV2(ctx context.Context, topic string, from int64, limit int64, c
return GetMessagesV2WithParameter(ctx, topic, from, limit, collection, false)
}

func GetMessagesV2WithParameter(ctx context.Context, topic string, from int64, limit int64, collection string, retrieve bool) []*models.MessageV2 {
func GetMessagesV2WithParameter(ctx context.Context, topic string, from int64, limit int64, collection string, isBlocked bool) []*models.MessageV2 {
rawResults := make([]MongoMessage, 0)

callback := func(coll *mongo.Collection) error {
Expand All @@ -52,7 +52,7 @@ func GetMessagesV2WithParameter(ctx context.Context, topic string, from int64, l
"timestamp": bson.M{
"$lte": from, // less than or equal
},
"blocked": retrieve,
"blocked": isBlocked,
}

sort := bson.D{
Expand Down

0 comments on commit a551eaf

Please sign in to comment.