@@ -393,8 +393,7 @@ def comment_submit_api(request): |
||
393 | 393 |
r.sadd(GROUP_PHOTO_WATCHER_SET % photo_id, user_id) |
394 | 394 |
|
395 | 395 |
# 判断群组照片发布者是否已经被管理员移除/主动退出,如若移除/退出,则不给发布者提醒 |
396 |
- # 照片所有者(评论/点赞)不给自己提醒 |
|
397 |
- if r.sismember(GROUP_USERS_PASSED_SET % group_photo.group_id, group_photo.user_id) and group_photo.user_id != user_id: |
|
396 |
+ if r.sismember(GROUP_USERS_PASSED_SET % group_photo.group_id, group_photo.user_id): |
|
398 | 397 |
UserMessageInfo.objects.create( |
399 | 398 |
from_uid=user_id, |
400 | 399 |
from_nickname=group_user.nickname, |
@@ -407,12 +406,8 @@ def comment_submit_api(request): |
||
407 | 406 |
msg_content=comment, |
408 | 407 |
) |
409 | 408 |
|
410 |
- # 给所有关注者(评论/点赞)发送提醒 |
|
411 |
- watchers = get_group_photo_watchers(photo_id) |
|
412 |
- # 从关注者中移除该(评论/点赞)者 |
|
413 |
- watchers.discard(user_id) |
|
414 |
- # 从关注者中移除该照片所有者 |
|
415 |
- watchers.discard(group_photo.user_id) |
|
409 |
+ # 给所有关注者(评论/点赞)发送提醒,移除(评论/点赞)者和照片所有者 |
|
410 |
+ watchers = get_group_photo_watchers(photo_id, [user_id, group_photo.user_id]) |
|
416 | 411 |
for watcher in watchers: |
417 | 412 |
UserMessageInfo.objects.create( |
418 | 413 |
from_uid=user_id, |
@@ -480,8 +475,7 @@ def thumbup_submit_api(request): |
||
480 | 475 |
r.sadd(GROUP_PHOTO_WATCHER_SET % photo_id, user_id) |
481 | 476 |
|
482 | 477 |
# 判断群组照片发布者是否已经被管理员移除/主动退出,如若移除/退出,则不给发布者提醒 |
483 |
- # 照片所有者(评论/点赞)不给自己提醒 |
|
484 |
- if r.sismember(GROUP_USERS_PASSED_SET % group_photo.group_id, group_photo.user_id) and group_photo.user_id != user_id: |
|
478 |
+ if r.sismember(GROUP_USERS_PASSED_SET % group_photo.group_id, group_photo.user_id): |
|
485 | 479 |
UserMessageInfo.objects.create( |
486 | 480 |
from_uid=user_id, |
487 | 481 |
from_nickname=group_user.nickname, |
@@ -494,12 +488,8 @@ def thumbup_submit_api(request): |
||
494 | 488 |
msg_content=u'点赞', |
495 | 489 |
) |
496 | 490 |
|
497 |
- # 给所有关注者(评论/点赞)发送提醒 |
|
498 |
- watchers = get_group_photo_watchers(photo_id) |
|
499 |
- # 从关注者中移除该(评论/点赞)者 |
|
500 |
- watchers.discard(user_id) |
|
501 |
- # 从关注者中移除该照片所有者 |
|
502 |
- watchers.discard(group_photo.user_id) |
|
491 |
+ # 给所有关注者(评论/点赞)发送提醒,移除(评论/点赞)者和照片所有者 |
|
492 |
+ watchers = get_group_photo_watchers(photo_id, [user_id, group_photo.user_id]) |
|
503 | 493 |
for watcher in watchers: |
504 | 494 |
UserMessageInfo.objects.create( |
505 | 495 |
from_uid=user_id, |
@@ -21,8 +21,6 @@ django-six==1.0.2 |
||
21 | 21 |
djangorestframework==3.5.3 |
22 | 22 |
furl==0.5.7 |
23 | 23 |
hiredis==0.2.0 |
24 |
-ipdb==0.10.1 |
|
25 |
-ipython==5.1.0 |
|
26 | 24 |
isoweek==1.3.3 |
27 | 25 |
jsonfield==2.0.1 |
28 | 26 |
mock==2.0.0 |
@@ -43,10 +43,10 @@ def retrieve_group_user_status(): |
||
43 | 43 |
def retrieve_group_photo_watchers(): |
44 | 44 |
group_photos = GroupPhotoInfo.objects.filter(status=True) |
45 | 45 |
for group_photo in group_photos: |
46 |
- photo_comments = PhotoCommentInfo.objects.filter(photo_id=group_photo.pk, status=True) |
|
46 |
+ photo_comments = PhotoCommentInfo.objects.filter(photo_id=group_photo.photo_id, status=True) |
|
47 | 47 |
for photo_comment in photo_comments: |
48 | 48 |
r.sadd(GROUP_PHOTO_WATCHER_SET % group_photo.pk, photo_comment.user_id) |
49 |
- photo_thumbups = PhotoThumbUpInfo.objects.filter(photo_id=group_photo.pk, status=True) |
|
49 |
+ photo_thumbups = PhotoThumbUpInfo.objects.filter(photo_id=group_photo.photo_id, status=True) |
|
50 | 50 |
for photo_thumbup in photo_thumbups: |
51 | 51 |
r.sadd(GROUP_PHOTO_WATCHER_SET % group_photo.pk, photo_thumbup.user_id) |
52 | 52 |
|
@@ -140,6 +140,8 @@ def get_group_photo_thumbup_list(photo_id): |
||
140 | 140 |
return r.getjson(GROUP_PHOTO_THUMB_UP_LIST % photo_id, default='[]') or set_group_photo_thumbup_list(photo_id) |
141 | 141 |
|
142 | 142 |
|
143 |
-def get_group_photo_watchers(photo_id): |
|
143 |
+def get_group_photo_watchers(photo_id, discarders=None): |
|
144 | 144 |
""" 获取群组照片用户关注列表 """ |
145 |
- return r.smembers(GROUP_PHOTO_WATCHER_SET % photo_id) |
|
145 |
+ watchers = r.smembers(GROUP_PHOTO_WATCHER_SET % photo_id) |
|
146 |
+ [watchers.discard(elem) for elem in discarders or []] |
|
147 |
+ return watchers |