1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 11:21:29 +00:00

Modify group msg notification to make index friendly.

This commit is contained in:
xiez
2012-06-26 18:09:36 +08:00
parent df4ac6ab02
commit 5be0aa3175
2 changed files with 16 additions and 8 deletions

View File

@@ -6,15 +6,22 @@ from seahub.notifications.models import UserNotification
def grpmsg_added_cb(sender, **kwargs): def grpmsg_added_cb(sender, **kwargs):
group_id = kwargs['group_id'] group_id = kwargs['group_id']
from_email = kwargs['from_email'] from_email = kwargs['from_email']
l = UserNotification.objects.filter(msg_type='group_msg', detail=group_id)
if len(l) == 0:
group_members = ccnet_threaded_rpc.get_group_members(int(group_id)) group_members = ccnet_threaded_rpc.get_group_members(int(group_id))
for m in group_members: for m in group_members:
if from_email == m.user_name: if from_email == m.user_name:
continue continue
try:
UserNotification.objects.get(to_user=m.user_name,
msg_type='group_msg',
detail=group_id)
except UserNotification.DoesNotExist:
n = UserNotification(to_user=m.user_name, msg_type='group_msg', n = UserNotification(to_user=m.user_name, msg_type='group_msg',
detail=group_id) detail=group_id)
n.save() n.save()
else:
pass

View File

@@ -142,6 +142,7 @@ def render_group_info(request, group_id, form):
# remove user notifications # remove user notifications
UserNotification.objects.filter(to_user=request.user.username, UserNotification.objects.filter(to_user=request.user.username,
msg_type='group_msg',
detail=str(group_id)).delete() detail=str(group_id)).delete()
"""group messages""" """group messages"""