Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6caf5bd079
|
||
|
|
74894278d8
|
@@ -25,7 +25,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Creating version"
|
echo "Creating version"
|
||||||
|
|
||||||
VERSION="0.0.8"
|
VERSION="0.1.0"
|
||||||
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
|
PROJECT_COMMIT_HASH=$(git rev-parse HEAD | cut -c 1-10)
|
||||||
BRANCH_REF="${{ gitea.ref }}"
|
BRANCH_REF="${{ gitea.ref }}"
|
||||||
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
||||||
|
|||||||
@@ -15,11 +15,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const Schedule_Type = "fixed"
|
const Schedule_Type = "fixed"
|
||||||
|
const Schedulable_Limit_In_Seconds = 300
|
||||||
|
|
||||||
type MessageSender struct {
|
type MessageSender struct {
|
||||||
Config *auxcfg.TwilioConfig
|
Config *auxcfg.TwilioConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sends a message to a contact via Twilio
|
||||||
|
// Has support for scheduling a time based on if it is in the future
|
||||||
func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTime *time.Time) (*types.TwilioResult, map[string]any, error) {
|
func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTime *time.Time) (*types.TwilioResult, map[string]any, error) {
|
||||||
if m.Config == nil {
|
if m.Config == nil {
|
||||||
return nil, nil, fmt.Errorf("Config has not been initialized")
|
return nil, nil, fmt.Errorf("Config has not been initialized")
|
||||||
@@ -57,7 +60,7 @@ func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isSchedulable(now *time.Time, scheduled *time.Time) bool {
|
func isSchedulable(now *time.Time, scheduled *time.Time) bool {
|
||||||
early := now.Add(300 * time.Second)
|
early := now.Add(Schedulable_Limit_In_Seconds * time.Second)
|
||||||
|
|
||||||
if scheduled.After(early) {
|
if scheduled.After(early) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user