fix_: log utc timestamp (#5672)
* fix_: log zone-agnostic time * chore_: use time.Truncate
This commit is contained in:
parent
58a9557c58
commit
01288227d3
|
@ -202,7 +202,7 @@ func main() {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
count++
|
count++
|
||||||
timestamp := time.Now().Format(time.RFC3339)
|
timestamp := time.Now().UTC().Format(time.RFC3339)
|
||||||
logger.Info("Publishing", "id", id, "count", count, "time", timestamp)
|
logger.Info("Publishing", "id", id, "count", count, "time", timestamp)
|
||||||
inputMessage := common.NewMessage()
|
inputMessage := common.NewMessage()
|
||||||
|
|
||||||
|
|
|
@ -1593,8 +1593,8 @@ func (m *Messenger) watchChatsAndCommunitiesToUnmute() {
|
||||||
case <-time.After(1 * time.Minute):
|
case <-time.After(1 * time.Minute):
|
||||||
response := &MessengerResponse{}
|
response := &MessengerResponse{}
|
||||||
m.allChats.Range(func(chatID string, c *Chat) bool {
|
m.allChats.Range(func(chatID string, c *Chat) bool {
|
||||||
chatMuteTill, _ := time.Parse(time.RFC3339, c.MuteTill.Format(time.RFC3339))
|
chatMuteTill := c.MuteTill.Truncate(time.Second)
|
||||||
currTime, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
currTime := time.Now().Truncate(time.Second)
|
||||||
|
|
||||||
if currTime.After(chatMuteTill) && !chatMuteTill.Equal(time.Time{}) && c.Muted {
|
if currTime.After(chatMuteTill) && !chatMuteTill.Equal(time.Time{}) && c.Muted {
|
||||||
err := m.persistence.UnmuteChat(c.ID)
|
err := m.persistence.UnmuteChat(c.ID)
|
||||||
|
|
|
@ -856,14 +856,8 @@ func (m *Messenger) CheckCommunitiesToUnmute() (*MessengerResponse, error) {
|
||||||
return nil, fmt.Errorf("couldn't get all communities: %v", err)
|
return nil, fmt.Errorf("couldn't get all communities: %v", err)
|
||||||
}
|
}
|
||||||
for _, community := range communities {
|
for _, community := range communities {
|
||||||
communityMuteTill, err := time.Parse(time.RFC3339, community.MuteTill().Format(time.RFC3339))
|
communityMuteTill := community.MuteTill().Truncate(time.Second)
|
||||||
if err != nil {
|
currTime := time.Now().Truncate(time.Second)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
currTime, err := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if currTime.After(communityMuteTill) && !communityMuteTill.Equal(time.Time{}) && community.Muted() {
|
if currTime.After(communityMuteTill) && !communityMuteTill.Equal(time.Time{}) && community.Muted() {
|
||||||
err := m.communitiesManager.SetMuted(community.ID(), false)
|
err := m.communitiesManager.SetMuted(community.ID(), false)
|
||||||
|
|
|
@ -201,7 +201,12 @@ func (rl *RPCRequestLimiter) Allow(tag string) (bool, error) {
|
||||||
// Check if a number of requests is over the limit within the interval
|
// Check if a number of requests is over the limit within the interval
|
||||||
if time.Since(data.CreatedAt) < data.Period || data.Period.Milliseconds() == LimitInfinitely {
|
if time.Since(data.CreatedAt) < data.Period || data.Period.Milliseconds() == LimitInfinitely {
|
||||||
if data.NumReqs >= data.MaxReqs {
|
if data.NumReqs >= data.MaxReqs {
|
||||||
log.Info("Number of requests over limit", "tag", tag, "numReqs", data.NumReqs, "maxReqs", data.MaxReqs, "period", data.Period, "createdAt", data.CreatedAt)
|
log.Info("Number of requests over limit",
|
||||||
|
"tag", tag,
|
||||||
|
"numReqs", data.NumReqs,
|
||||||
|
"maxReqs", data.MaxReqs,
|
||||||
|
"period", data.Period,
|
||||||
|
"createdAt", data.CreatedAt.UTC())
|
||||||
return false, ErrRequestsOverLimit
|
return false, ErrRequestsOverLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue