Skip to content

Commit

Permalink
temp disable unfollow
Browse files Browse the repository at this point in the history
  • Loading branch information
asymmetric committed Jan 13, 2025
1 parent 7444f2c commit e00d6e8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ These are the available commands:
- **sub foo**: subscribe to package <code>foo</code>
- **unsub foo**: unsubscribe from package <code>foo</code>
- **follow foo**: subscribe to all packages maintained by Nixpkgs maintainer <code>foo</code>
- **unfollow foo**: unsubscribe to all packages maintained by Nixpkgs maintainer <code>foo</code>
- **subs**: list subscriptions
- **help**: show this help message
Expand Down
13 changes: 3 additions & 10 deletions message_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ func handleSubs(evt *event.Event) {

func handleFollowUnfollow(msg string, evt *event.Event) {
matches := regexes.Follow().FindStringSubmatch(msg)
un := matches[1]
handle := matches[2]
handle := matches[1]
pjson := h.packagesJSONFetcher()

slog.Info("received follow", "handle", handle, "sender", evt.Sender)
Expand All @@ -178,16 +177,10 @@ func handleFollowUnfollow(msg string, evt *event.Event) {
}
}

if un != "" {
if _, err := clients.db.Exec("DELETE FROM subscriptions WHERE mxid = ? AND attr_path IN ?", evt.Sender, aps); err != nil {
for _, ap := range aps {
if err := subscribe(ap, evt); err != nil {
panic(err)
}
} else {
for _, ap := range aps {
if err := subscribe(ap, evt); err != nil {
panic(err)
}
}
}

var l []string
Expand Down
2 changes: 1 addition & 1 deletion regexes/regexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "regexp"
var (
dangerous = regexp.MustCompile(`^sub (?:[*?]+|\w+\.\*)$`)
subscribe = regexp.MustCompile(`^(un)?sub ([\w_?*.-]+)$`)
follow = regexp.MustCompile(`^(un)?follow (\w+)$`)
follow = regexp.MustCompile(`^follow (\w+)$`)
)

// These two regexps are for parsing logs.
Expand Down
1 change: 0 additions & 1 deletion regexes/regexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func TestFollowRegexp(t *testing.T) {
t.Run("should match", func(t *testing.T) {
ss := []string{
"follow foo",
"unfollow bar",
}
for _, s := range ss {
if !Follow().MatchString(s) {
Expand Down

0 comments on commit e00d6e8

Please sign in to comment.