From 68887f13d57472b8b68d14d01700f4b13282100b Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sun, 14 Apr 2024 13:12:19 +0200 Subject: [PATCH] Rename tokens.Edit to Extend. --- rtpconn/webclient.go | 2 +- token/stateful.go | 10 +++++----- token/stateful_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index f4fe2be..5d6aae8 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -1793,7 +1793,7 @@ func handleClientMessage(c *webClient, m clientMessage) error { if tok.Expires == nil { return terror("error", "trying to edit nothing") } - new, err := token.Edit( + new, err := token.Extend( c.group.Name(), tok.Token, *tok.Expires, ) if err != nil { diff --git a/token/stateful.go b/token/stateful.go index a25bf35..45f1813 100644 --- a/token/stateful.go +++ b/token/stateful.go @@ -217,18 +217,18 @@ func Add(token *Stateful) (*Stateful, error) { return tokens.Add(token) } -func Edit(group, token string, expires time.Time) (*Stateful, error) { - return tokens.Edit(group, token, expires) +func Extend(group, token string, expires time.Time) (*Stateful, error) { + return tokens.Extend(group, token, expires) } -func (state *state) Edit(group, token string, expires time.Time) (*Stateful, error) { +func (state *state) Extend(group, token string, expires time.Time) (*Stateful, error) { tokens.mu.Lock() defer tokens.mu.Unlock() - return state.edit(group, token, expires) + return state.extend(group, token, expires) } // called locked -func (state *state) edit(group, token string, expires time.Time) (*Stateful, error) { +func (state *state) extend(group, token string, expires time.Time) (*Stateful, error) { err := state.load() if err != nil { return nil, err diff --git a/token/stateful_test.go b/token/stateful_test.go index a5e9264..9a88179 100644 --- a/token/stateful_test.go +++ b/token/stateful_test.go @@ -269,11 +269,11 @@ func TestTokenStorage(t *testing.T) { } expectTokens(t, s.tokens, tokens) - _, err = s.Edit("test2", tokens[1].Token, now.Add(time.Hour)) + _, err = s.Extend("test2", tokens[1].Token, now.Add(time.Hour)) if err == nil { t.Errorf("Edit succeeded with wrong group") } - new, err := s.Edit("test", tokens[1].Token, now.Add(time.Hour)) + new, err := s.Extend("test", tokens[1].Token, now.Add(time.Hour)) if err != nil { t.Errorf("Edit: %v", err) }