# Como desativar em massa os resumos para alguns usuários?

**URL:** https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215
**Category:** Support
**Tags:** activity-summary
**Created:** [Novembro 3, 2018, 3:48pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215 "2018-11-03T15:48:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [Novembro 3, 2018, 3:48pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/1 "2018-11-03T15:48:46Z")

</div>

Is there a way to disable digest emails from some users via the Rails console like in the example code below? I’m trying to read in from a list and turn off the digest emails if that email address is in the list. The line `u.user_option.email_digests = false` doesn’t seem to change the setting on the user settings page. (I tried it on just my own user account to test it and haven’t run the rest of the code yet.)

```ruby
# rails c
users = User.all.select { |u| u.id > 0 }
processed_users = []
txt = File.open('no_email_digest_list.txt').read
lines = txt.split("\n")
h = lines.map { |x| [x.strip, true] }.to_h

users.each do |u|
  if h.has_key? u.email
    u.user_option.email_digests = false
    u.save
    processed_users << u.email
    # puts u.email # dry run
  end
end

puts "updated #{processed_users.count} users"

```

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [Novembro 3, 2018, 4:27pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/2 "2018-11-03T16:27:51Z")

</div>

This should be enough

```plaintext
cd /var/discourse
./launcher enter app
rails c
SiteSetting.disable_digest_emails = true

```

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [Novembro 3, 2018, 4:45pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/3 "2018-11-03T16:45:36Z")

</div>

I’m only disabling it for about 1,500 accounts at the moment, not all the users. Is there a way to only disable it for users whose email addresses appear in a text file?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [Novembro 3, 2018, 5:12pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/4 "2018-11-03T17:12:39Z")

</div>

I couldn’t figure out why it wouldn’t work either, but it’s because you need to save `u.user_option`, not `u`!

```plaintext
u.user_option.save

```

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [Novembro 3, 2018, 9:13pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/5 "2018-11-03T21:13:21Z")

</div>

Thanks, that worked.

This isn’t exactly related, but it’s another email problem – does anyone know why my new install isn’t sending emails for private messages or forum replies? It’s sending some types of emails – even a digest to me (because I’m the only user who has them set for every 30 minutes).

In the screenshot below, we’ve sent several private messages back and forth, but none of them appear to have been sent out by Discourse. It was working before the user import. I had these settings in the import script but have already reverted them. The users all do have emails enabled for private messages and mentions.

```ruby
    SiteSetting.disable_emails = "non-staff"
    SiteSetting.allow_index_in_robots_txt = nil
    SiteSetting.login_required = true

```

 ![discourse-email-problem](https://global.discourse-cdn.com/meta/original/3X/e/0/e077d9a219a526c65b40a3ed02f83e8d3b5af0ea.png)

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [Novembro 3, 2018, 10:13pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/6 "2018-11-03T22:13:59Z")

</div>

It appears that some of the emails finally sent, about 5 hours after being posted. I found the `/sidekiq` route, and it looks like there are many jobs queued after the import, so maybe that was the problem.

Thanks again for the help.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [Dezembro 3, 2018, 10:15pm UTC](https://meta.discourse.org/t/how-to-bulk-disable-digests-for-some-users/101215/7 "2018-12-03T22:15:16Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
