Skip to content

Commit

Permalink
Merge pull request #11 from micr0-dev/fix/consentprecheck
Browse files Browse the repository at this point in the history
Pre-checks for consent asking
  • Loading branch information
micr0-dev authored Dec 3, 2024
2 parents 793ff70 + a72832e commit a55908d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,24 @@ func handleMention(c *mastodon.Client, notification *mastodon.Notification) {

// requestConsent asks the original poster for consent to generate alt text
func requestConsent(c *mastodon.Client, status *mastodon.Status, notification *mastodon.Notification) {
// Check if every image in the post already has a Alt text
hasAltText := true

for _, attachment := range status.MediaAttachments {
if attachment.Type == "image" && attachment.Description == "" {
hasAltText = false
}
}

if hasAltText {
return
}

// Check if the original poster has already been asked for consent
if _, ok := consentRequests[status.ID]; ok {
return
}

consentRequests[status.ID] = notification.Status.ID

message := fmt.Sprintf("@%s "+getLocalizedString(notification.Status.Language, "consentRequest", "response"), status.Account.Acct, notification.Account.Acct)
Expand Down

0 comments on commit a55908d

Please sign in to comment.