|
a/Allura/allura/model/notification.py |
|
b/Allura/allura/model/notification.py |
|
... |
|
... |
239 |
artifact=None, topic=None,
|
239 |
artifact=None, topic=None,
|
240 |
type='direct', n=1, unit='day'):
|
240 |
type='direct', n=1, unit='day'):
|
241 |
if user_id is None: user_id = c.user._id
|
241 |
if user_id is None: user_id = c.user._id
|
242 |
if project_id is None: project_id = c.project._id
|
242 |
if project_id is None: project_id = c.project._id
|
243 |
if app_config_id is None: app_config_id = c.app.config._id
|
243 |
if app_config_id is None: app_config_id = c.app.config._id
|
|
|
244 |
tool_already_subscribed = cls.query.get(
|
|
|
245 |
user_id=user_id, project_id=project_id, app_config_id=app_config_id,
|
|
|
246 |
artifact_index_id=None)
|
|
|
247 |
if tool_already_subscribed:
|
|
|
248 |
log.warning('Tried to subscribe to artifact %s, while there is a tool subscription', artifact)
|
|
|
249 |
return
|
244 |
if artifact is None:
|
250 |
if artifact is None:
|
245 |
artifact_title = 'All artifacts'
|
251 |
artifact_title = 'All artifacts'
|
246 |
artifact_url = None
|
252 |
artifact_url = None
|
247 |
artifact_index_id = None
|
253 |
artifact_index_id = None
|
248 |
else:
|
254 |
else:
|
249 |
i = artifact.index()
|
255 |
i = artifact.index()
|
250 |
artifact_title = i['title_s']
|
256 |
artifact_title = i['title_s']
|
251 |
artifact_url = artifact.url()
|
257 |
artifact_url = artifact.url()
|
252 |
artifact_index_id = i['id']
|
258 |
artifact_index_id = i['id']
|
253 |
if cls.query.get(
|
|
|
254 |
user_id=user_id, project_id=project_id, app_config_id=app_config_id,
|
|
|
255 |
artifact_index_id=None):
|
|
|
256 |
# don't subscribe to individual artifacts when already
|
|
|
257 |
# subscribed to tool
|
|
|
258 |
log.warning('Tried to subscribe to artifact %s, while there is a tool subscription', artifact_url)
|
|
|
259 |
return
|
|
|
260 |
d = dict(user_id=user_id, project_id=project_id, app_config_id=app_config_id,
|
259 |
d = dict(user_id=user_id, project_id=project_id, app_config_id=app_config_id,
|
261 |
artifact_index_id=artifact_index_id, topic=topic)
|
260 |
artifact_index_id=artifact_index_id, topic=topic)
|
262 |
sess = session(cls)
|
261 |
sess = session(cls)
|
263 |
try:
|
262 |
try:
|
264 |
mbox = cls(
|
263 |
mbox = cls(
|