Skip to content

Commit

Permalink
Compose wlecome message with expire time
Browse files Browse the repository at this point in the history
  • Loading branch information
berejant committed Nov 8, 2023
1 parent 11e85e5 commit 3aa4041
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions MessageComposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (composer *MessageComposer) SetPostFilter(filter func(string) string) {
composer.postFilter = filter
}

func (composer *MessageComposer) ComposeWelcomeAnonymousMessage(authUrl string) (error, string) {
return composer.compose("WelcomeAnonymous.md", authUrl)
func (composer *MessageComposer) ComposeWelcomeAnonymousMessage(messageData models.WelcomeAnonymousMessageData) (error, string) {
return composer.compose("WelcomeAnonymous.md", messageData)
}

func (composer *MessageComposer) ComposeWelcomeAuthorizedMessage(messageData models.UserAuthorizedMessageData) (error, string) {
Expand Down
2 changes: 1 addition & 1 deletion MessageComposerInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/kneu-messenger-pigeon/client-framework/models"

type MessageComposerInterface interface {
SetPostFilter(filter func(string) string)
ComposeWelcomeAnonymousMessage(authUrl string) (error, string)
ComposeWelcomeAnonymousMessage(messageData models.WelcomeAnonymousMessageData) (error, string)
ComposeWelcomeAuthorizedMessage(messageData models.UserAuthorizedMessageData) (error, string)
ComposeDisciplinesListMessage(messageData models.DisciplinesListMessageData) (error, string)
ComposeDisciplineScoresMessage(messageData models.DisciplinesScoresMessageData) (error, string)
Expand Down
8 changes: 7 additions & 1 deletion MessageComposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ func TestMessageComposer_ComposeWelcomeAnonymousMessage(t *testing.T) {

authUrl := "https://example.com/auth"

err, message := composer.ComposeWelcomeAnonymousMessage(authUrl)
messageData := models.WelcomeAnonymousMessageData{
AuthUrl: authUrl,
ExpireAt: time.Date(2024, 5, 15, 16, 25, 0, 0, time.Local),
}

err, message := composer.ComposeWelcomeAnonymousMessage(messageData)

assert.NoError(t, err)
assert.Contains(t, message, authUrl)
assert.Contains(t, message, "до 16:25")
})
}

Expand Down
18 changes: 9 additions & 9 deletions mocks/MessageComposerInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions models/MessageData.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ package models

import (
scoreApi "github.com/kneu-messenger-pigeon/score-api"
"time"
)

type WelcomeAnonymousMessageData struct {
AuthUrl string
ExpireAt time.Time
}

type StudentMessageData struct {
NamePrefix string
Name string
Expand Down
3 changes: 2 additions & 1 deletion templates/WelcomeAnonymous.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Для запуску Telegram боту електронного журналу необхідно [пройти авторизацію на сайті КНЕУ]({{.}})
Для запуску Telegram боту електронного журналу необхідно [пройти авторизацію на сайті КНЕУ]({{.AuthUrl}}).
Посилання дійсне до {{ .ExpireAt.Format "15:04" }}.

0 comments on commit 3aa4041

Please sign in to comment.