Skip to content

Commit d11d5ef

Browse files
committed
Added listeners to create subscriptions
1 parent f844604 commit d11d5ef

3 files changed

Lines changed: 34 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ tickets and which are not.
7070
* Notifications – if you have configured Trac to email ticket notifications
7171
then comment notifications will just work!
7272

73+
* Subscriptions – Authors of changesets and attachments, and anyone who
74+
creates a comment are subscribed to notifications of comments; to have changeset authors automatically subscribed, your repositories must be configured for [synchronisation](http://trac.edgewall.org/wiki/TracRepositoryAdmin#Synchronization) with Trac
75+
7376
Screenshots
7477
-----------
7578

code_comments/subscription.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from trac.admin import IAdminCommandProvider
2-
from trac.attachment import Attachment
2+
from trac.attachment import Attachment, IAttachmentChangeListener
33
from trac.core import Component, implements
4-
from trac.versioncontrol import RepositoryManager, NoSuchChangeset
4+
from trac.versioncontrol import (
5+
RepositoryManager, NoSuchChangeset, IRepositoryChangeListener)
56

7+
from code_comments.api import ICodeCommentChangeListener
68
from code_comments.comments import Comments
79

810

@@ -200,3 +202,27 @@ def _do_seed(self):
200202
comments = Comments(None, self.env).all()
201203
for comment in comments:
202204
Subscription.from_comment(self.env, comment)
205+
206+
207+
class SubscriptionListeners(Component):
208+
"""
209+
Automatically creates subscriptions for attachments, changesets, and
210+
comments.
211+
"""
212+
implements(IAttachmentChangeListener, IRepositoryChangeListener,
213+
ICodeCommentChangeListener)
214+
215+
# IAttachmentChangeListener methods
216+
217+
def attachment_added(self, attachment):
218+
Subscription.from_attachment(self.env, attachment)
219+
220+
# IRepositoryChangeListener methods
221+
222+
def changeset_added(self, repos, changeset):
223+
Subscription.from_changeset(self.env, changeset)
224+
225+
# ICodeCommentChangeListener methods
226+
227+
def comment_created(self, comment):
228+
Subscription.from_comment(self.env, comment)

todo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Need to figure out how to handle blanket subscriptions.
3232

3333
## Listeners
3434

35-
- [ ] comments_created - create a subscription for the comment author
36-
- [ ] attachment_added - create a subscription for the attachment author
35+
- [x] comments_created - create a subscription for the comment author
36+
- [x] attachment_added - create a subscription for the attachment author
3737
- [ ] attachment_deleted - remove all subscriptions for the attachment (should we also remove all comments?)
3838
- [ ] attachment_reparented - update all subscriptions for the attachment
39-
- [ ] changeset_added - create a subscription for the changeset author
39+
- [x] changeset_added - create a subscription for the changeset author
4040
- [ ] changeset_modified - update the subscription (author?)

0 commit comments

Comments
 (0)