Adding count to activity for exported OPML, for #1646.

This commit is contained in:
Samuel Clay 2022-03-14 15:52:22 -04:00
parent 93fb2dde12
commit 3a260fb2f7
4 changed files with 10 additions and 6 deletions

View file

@ -106,7 +106,11 @@ class OPMLExporter(Importer):
except Feed.DoesNotExist:
continue
self.feeds = dict(self.feeds)
@property
def feed_count(self):
return len(self.feeds)
class OPMLImporter(Importer):

View file

@ -83,7 +83,7 @@ def opml_export(request):
opml = exporter.process()
from apps.social.models import MActivity
MActivity.new_opml_export(user_id=user.pk)
MActivity.new_opml_export(user_id=user.pk, count=exporter.feed_count)
response = HttpResponse(opml, content_type='text/xml; charset=utf-8')
response['Content-Disposition'] = 'attachment; filename=NewsBlur-%s-%s.opml' % (

View file

@ -759,7 +759,7 @@ class Profile(models.Model):
msg.send(fail_silently=True)
from apps.social.models import MActivity
MActivity.new_opml_export(user_id=self.user.pk, automated=True)
MActivity.new_opml_export(user_id=self.user.pk, count=exporter.feed_count, automated=True)
logging.user(self.user, "~BB~FM~SBSending OPML backup email to: %s" % self.user.email)

View file

@ -3232,14 +3232,14 @@ class MActivity(mongo.Document):
cls.objects.create(**params)
@classmethod
def new_opml_export(cls, user_id, automated=False):
def new_opml_export(cls, user_id, count, automated=False):
params = {
"user_id": user_id,
"category": 'opml_export',
'content': "You exported an OPML backup of your subscriptions"
'content': f"You exported an OPML backup of {count} subscriptions"
}
if automated:
params['content'] = "An automatic OPML backup was emailed to you"
params['content'] = f"An automatic OPML backup of {count} subscriptions was emailed to you"
cls.objects.create(**params)
@classmethod