-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup: credentials: remove old code
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ import ( | |
"github.com/grokify/oauth2more/sparkpost" | ||
) | ||
|
||
const DefaultExampleEmail = "[email protected]" | ||
|
||
type appConfig struct { | ||
SparkPostApiKey string `env:"SPARKPOST_API_KEY"` | ||
SparkPostEmailSender string `env:"SPARKPOST_EMAIL_SENDER"` | ||
|
@@ -31,6 +33,10 @@ func sendTestEmail(cfg appConfig, client sp.Client) { | |
day := 811 // Change this to set the day. This currently uses single digit month + 2 digit day | ||
seq := 0 // Sequence index. Start with 0 and increment. This demo doesn't support changing the day when changing sequence. | ||
|
||
if len(strings.TrimSpace(cfg.SparkPostEmailRecipientDemo)) == 0 { | ||
cfg.SparkPostEmailRecipientDemo = DefaultExampleEmail | ||
} | ||
|
||
format := `BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:-//MY COMPANY//Calendar//EN | ||
|
@@ -72,6 +78,7 @@ END:VCALENDAR` | |
attendee, uid2, day, day, dtNow, seq) | ||
|
||
fmt.Println(data) | ||
panic("z") | ||
attach := sp.Attachment{ | ||
MIMEType: hum.ContentTypeTextCalendarUtf8Request, | ||
B64Data: base64.StdEncoding.EncodeToString([]byte(data))} | ||
|
@@ -97,6 +104,56 @@ END:VCALENDAR` | |
Str("email-id", id) | ||
} | ||
|
||
func buildExampleIcs(recipientSmtpAddr string, dtStart, dtEnd time.Time, seq uint) string { | ||
if len(strings.TrimSpace(recipientSmtpAddr)) == 0 { | ||
recipientSmtpAddr = DefaultExampleEmail | ||
} | ||
// seq = Sequence index. Start with 0 and increment. This demo doesn't support changing the day when changing sequence. | ||
|
||
day := 811 // Change this to set the day. This currently uses single digit month + 2 digit day | ||
|
||
format := `BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:-//MY COMPANY//Calendar//EN | ||
CALSCALE:GREGORIAN | ||
METHOD:%v | ||
BEGIN:VEVENT | ||
%vUID:shift-%[email protected] | ||
DTSTART:20180%vT010000 | ||
DTEND:20180%vT020000 | ||
DTSTAMP:%v | ||
SEQUENCE:%v | ||
SUMMARY:Morning shift | ||
LOCATION:Morning Location | ||
DESCRIPTION:Morning shift | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
%vUID:shift-%[email protected] | ||
DTSTART:20180%vT130000 | ||
DTEND:20180%vT140000 | ||
DTSTAMP:%v | ||
SEQUENCE:%v | ||
SUMMARY:Night shift | ||
LOCATION:Night Location | ||
DESCRIPTION:Night | ||
END:VEVENT | ||
END:VCALENDAR` | ||
|
||
//attenddee needed for both events | ||
attendee := fmt.Sprintf( | ||
"ATTENDEE;ROLE=REQ-PARTICIPANT;CN=%s:MAILTO:%s\n", | ||
recipientSmtpAddr, recipientSmtpAddr) | ||
|
||
uid1 := day + 1000 | ||
uid2 := uid1 + 1 | ||
dtNow := time.Now().Format(tu.ISO8601CompactNoTZ) | ||
icsData := fmt.Sprintf( | ||
format, "REQUEST", | ||
attendee, uid1, day, day, dtNow, seq, | ||
attendee, uid2, day, day, dtNow, seq) | ||
return icsData | ||
} | ||
|
||
func main() { | ||
envFiles := []string{os.Getenv("ENV_PATH"), "./.env"} | ||
if err := config.LoadDotEnvSkipEmpty(envFiles...); err != nil { | ||
|