···
var _ notify.Notifier = &EmailNotifier{}
-
// TODO: yeah this is just bad design. should be moved under idResolver ore include repoResolver at first place
-
func (n *EmailNotifier) repoOwnerSlashName(ctx context.Context, repo *db.Repo) (string, error) {
repoOwnerID, err := n.idResolver.ResolveIdent(ctx, repo.Did)
if err != nil || repoOwnerID.Handle.IsInvalidHandle() {
-
return "", fmt.Errorf("resolve comment owner did: %w", err)
repoOwnerHandle := repoOwnerID.Handle
var repoOwnerSlashName string
···
repoOwnerSlashName = repo.DidSlashRepo()
-
return repoOwnerSlashName, nil
-
func (n *EmailNotifier) buildIssueEmail(ctx context.Context, repo *db.Repo, issue *db.Issue, comment *db.Comment, did string) (Email, error) {
-
// TODO: check email preferences
-
email, err := db.GetPrimaryEmail(n.db, did)
-
return Email{}, fmt.Errorf("db.GetPrimaryEmail: %w", err)
-
commentOwner, err := n.idResolver.ResolveIdent(ctx, comment.OwnerDid)
-
if err != nil || commentOwner.Handle.IsInvalidHandle() {
-
return Email{}, fmt.Errorf("resolve comment owner did: %w", err)
// TODO: make this configurable
baseUrl := "https://tangled.sh"
-
repoOwnerSlashName, err := n.repoOwnerSlashName(ctx, repo)
url := fmt.Sprintf("%s/%s/issues/%d#comment-%d", baseUrl, repoOwnerSlashName, comment.Issue, comment.CommentId)
APIKey: n.Config.Resend.ApiKey,
···
-
func (n *EmailNotifier) buildPullEmail(ctx context.Context, repo *db.Repo, pull *db.Pull, comment *db.PullComment, did string) (Email, error) {
-
// TODO: check email preferences
-
email, err := db.GetPrimaryEmail(n.db, did)
-
return Email{}, fmt.Errorf("db.GetPrimaryEmail: %w", err)
-
commentOwner, err := n.idResolver.ResolveIdent(ctx, comment.OwnerDid)
-
if err != nil || commentOwner.Handle.IsInvalidHandle() {
-
return Email{}, fmt.Errorf("resolve comment owner did: %w", err)
-
repoOwnerSlashName, err := n.repoOwnerSlashName(ctx, repo)
-
// TODO: make this configurable
-
baseUrl := "https://tangled.sh"
-
url := fmt.Sprintf("%s/%s/pulls/%d#comment-%d", baseUrl, repoOwnerSlashName, comment.PullId, comment.ID)
-
APIKey: n.Config.Resend.ApiKey,
-
From: n.Config.Resend.SentFrom,
-
Subject: fmt.Sprintf("[%s] %s (pr#%d)", repoOwnerSlashName, pull.Title, pull.PullId),
-
Html: fmt.Sprintf(`<p><b>@%s</b> mentioned you:</p><a href="%s">View it on tangled.sh</a>.`, commentOwner.Handle.String(), url),
func (n *EmailNotifier) NewIssueComment(ctx context.Context, repo *db.Repo, issue *db.Issue, comment *db.Comment, mentions []string) {
resolvedIds := n.idResolver.ResolveIdents(ctx, mentions)
handleDidMap := make(map[string]string)
···
-
func (n *EmailNotifier) NewPullComment(ctx context.Context, repo *db.Repo, pull *db.Pull, comment *db.PullComment, mentions []string) {
-
resolvedIds := n.idResolver.ResolveIdents(ctx, mentions)
-
handleDidMap := make(map[string]string)
-
for _, identity := range resolvedIds {
-
if !identity.Handle.IsInvalidHandle() {
-
handleDidMap[identity.Handle.String()] = identity.DID.String()
-
for _, handle := range mentions {
-
id, err := n.idResolver.ResolveIdent(ctx, handle)
-
email, err := n.buildPullEmail(ctx, repo, pull, comment, id.DID.String())
-
log.Println("failed to create issue-email:", err)
···
var _ notify.Notifier = &EmailNotifier{}
+
func (n *EmailNotifier) buildIssueEmail(ctx context.Context, repo *db.Repo, issue *db.Issue, comment *db.Comment, did string) (Email, error) {
+
// TODO: check email preferences
+
email, err := db.GetPrimaryEmail(n.db, did)
+
return Email{}, fmt.Errorf("db.GetPrimaryEmail: %w", err)
+
commentOwner, err := n.idResolver.ResolveIdent(ctx, comment.OwnerDid)
+
if err != nil || commentOwner.Handle.IsInvalidHandle() {
+
return Email{}, fmt.Errorf("resolve comment owner did: %w", err)
repoOwnerID, err := n.idResolver.ResolveIdent(ctx, repo.Did)
if err != nil || repoOwnerID.Handle.IsInvalidHandle() {
+
return Email{}, fmt.Errorf("resolve repo owner did: %w", err)
repoOwnerHandle := repoOwnerID.Handle
var repoOwnerSlashName string
···
repoOwnerSlashName = repo.DidSlashRepo()
// TODO: make this configurable
baseUrl := "https://tangled.sh"
url := fmt.Sprintf("%s/%s/issues/%d#comment-%d", baseUrl, repoOwnerSlashName, comment.Issue, comment.CommentId)
APIKey: n.Config.Resend.ApiKey,
···
func (n *EmailNotifier) NewIssueComment(ctx context.Context, repo *db.Repo, issue *db.Issue, comment *db.Comment, mentions []string) {
resolvedIds := n.idResolver.ResolveIdents(ctx, mentions)
handleDidMap := make(map[string]string)
···
+
// func (n *EmailNotifier) NewPullComment(ctx context.Context, comment *db.PullComment, []string) {
+
// n.usersMentioned(ctx, mentions)