Skip to content

Commit

Permalink
fix inability to unfollow the same user twice
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Oct 1, 2023
1 parent 0a2be75 commit 394518b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion outbox/unfollow.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import (
"github.com/dimkr/tootik/ap"
"github.com/dimkr/tootik/cfg"
"log/slog"
"time"
)

func Unfollow(ctx context.Context, log *slog.Logger, db *sql.DB, follower *ap.Actor, followed, followID string) error {
if followed == follower.ID {
return fmt.Errorf("%s cannot unfollow %s", follower.ID, followed)
}

undoID := fmt.Sprintf("https://%s/undo/%x", cfg.Domain, sha256.Sum256([]byte(fmt.Sprintf("%s|%s", follower.ID, followed))))
undoID := fmt.Sprintf("https://%s/undo/%x", cfg.Domain, sha256.Sum256([]byte(fmt.Sprintf("%s|%s|%d", follower.ID, followed, time.Now().UnixNano()))))

to := ap.Audience{}
to.Add(followed)
Expand Down

0 comments on commit 394518b

Please sign in to comment.