@@ -25,7 +25,7 @@ from utils.error.response_utils import response |
||
| 25 | 25 |
from utils.page_utils import pagination |
| 26 | 26 |
from utils.redis.rgroup import (del_group_photo_thumbup_flag, get_group_info, get_group_photo_comment_list, |
| 27 | 27 |
get_group_photo_data, get_group_photo_thumbup_flag, get_group_photo_thumbup_list, |
| 28 |
- get_group_users_info, set_group_info, set_group_photo_data, |
|
| 28 |
+ get_group_photo_watchers, get_group_users_info, set_group_info, set_group_photo_data, |
|
| 29 | 29 |
set_group_photo_thumbup_flag, set_group_users_info) |
| 30 | 30 |
from utils.redis.rkeys import (GROUP_LAST_PHOTO_PK, GROUP_USERS_APPLYING_SET, GROUP_USERS_DELETED_SET, |
| 31 | 31 |
GROUP_USERS_PASSED_SET, GROUP_USERS_QUIT_SET, GROUP_USERS_REFUSED_SET, |
@@ -683,43 +683,25 @@ def comment_submit_api(request): |
||
| 683 | 683 |
msg_content=comment, |
| 684 | 684 |
) |
| 685 | 685 |
|
| 686 |
- # 群组照片评论列表 |
|
| 687 |
- photo_comments = get_group_photo_comment_list(photo_id) |
|
| 688 |
- |
|
| 689 |
- # 群组照片点赞列表 |
|
| 690 |
- photo_thumbups = get_group_photo_thumbup_list(photo_id) |
|
| 691 |
- |
|
| 692 |
- # 给所有评论/点赞者发送提醒 |
|
| 693 |
- for commenter in photo_comments: |
|
| 694 |
- UserMessageInfo.objects.create( |
|
| 695 |
- from_uid=user_id, |
|
| 696 |
- from_nickname=group_user.nickname, |
|
| 697 |
- from_avatar=group_user.avatar, |
|
| 698 |
- to_uid=commenter['user_id'], |
|
| 699 |
- group_id=group_photo.group_id, |
|
| 700 |
- photo_id=group_photo.pk, |
|
| 701 |
- msg_type=UserMessageInfo.COMMENT, |
|
| 702 |
- msg_title=u'评论', |
|
| 703 |
- msg_content=comment, |
|
| 704 |
- ) |
|
| 705 |
- for thumber in photo_thumbups: |
|
| 706 |
- UserMessageInfo.objects.create( |
|
| 707 |
- from_uid=user_id, |
|
| 708 |
- from_nickname=group_user.nickname, |
|
| 709 |
- from_avatar=group_user.avatar, |
|
| 710 |
- to_uid=thumber['user_id'], |
|
| 711 |
- group_id=group_photo.group_id, |
|
| 712 |
- photo_id=group_photo.pk, |
|
| 713 |
- msg_type=UserMessageInfo.COMMENT, |
|
| 714 |
- msg_title=u'评论', |
|
| 715 |
- msg_content=comment, |
|
| 716 |
- ) |
|
| 686 |
+ # 给所有关注者(评论/点赞)发送提醒 |
|
| 687 |
+ for watcher in get_group_photo_watchers(photo_id): |
|
| 688 |
+ UserMessageInfo.objects.create( |
|
| 689 |
+ from_uid=user_id, |
|
| 690 |
+ from_nickname=group_user.nickname, |
|
| 691 |
+ from_avatar=group_user.avatar, |
|
| 692 |
+ to_uid=watcher, |
|
| 693 |
+ group_id=group_photo.group_id, |
|
| 694 |
+ photo_id=group_photo.pk, |
|
| 695 |
+ msg_type=UserMessageInfo.COMMENT, |
|
| 696 |
+ msg_title=u'评论', |
|
| 697 |
+ msg_content=comment, |
|
| 698 |
+ ) |
|
| 717 | 699 |
|
| 718 | 700 |
return JsonResponse({
|
| 719 | 701 |
'status': 200, |
| 720 | 702 |
'message': u'评论成功', |
| 721 | 703 |
'data': {
|
| 722 |
- 'comments': photo_comments, |
|
| 704 |
+ 'comments': get_group_photo_comment_list(photo_id), |
|
| 723 | 705 |
} |
| 724 | 706 |
}) |
| 725 | 707 |
|
@@ -784,31 +766,13 @@ def thumbup_submit_api(request): |
||
| 784 | 766 |
msg_content=u'点赞', |
| 785 | 767 |
) |
| 786 | 768 |
|
| 787 |
- # 群组照片评论列表 |
|
| 788 |
- photo_comments = get_group_photo_comment_list(photo_id) |
|
| 789 |
- |
|
| 790 |
- # 群组照片点赞列表 |
|
| 791 |
- photo_thumbups = get_group_photo_thumbup_list(photo_id) |
|
| 792 |
- |
|
| 793 |
- # 给所有评论/点赞者发送提醒 |
|
| 794 |
- for commenter in photo_comments: |
|
| 795 |
- UserMessageInfo.objects.create( |
|
| 796 |
- from_uid=user_id, |
|
| 797 |
- from_nickname=group_user.nickname, |
|
| 798 |
- from_avatar=group_user.avatar, |
|
| 799 |
- to_uid=commenter['user_id'], |
|
| 800 |
- group_id=group_photo.group_id, |
|
| 801 |
- photo_id=group_photo.pk, |
|
| 802 |
- msg_type=UserMessageInfo.THUMBUP, |
|
| 803 |
- msg_title=u'点赞', |
|
| 804 |
- msg_content=u'点赞', |
|
| 805 |
- ) |
|
| 806 |
- for thumber in photo_thumbups: |
|
| 769 |
+ # 给所有关注者(评论/点赞)发送提醒 |
|
| 770 |
+ for watcher in get_group_photo_watchers(photo_id): |
|
| 807 | 771 |
UserMessageInfo.objects.create( |
| 808 | 772 |
from_uid=user_id, |
| 809 | 773 |
from_nickname=group_user.nickname, |
| 810 | 774 |
from_avatar=group_user.avatar, |
| 811 |
- to_uid=thumber['user_id'], |
|
| 775 |
+ to_uid=watcher, |
|
| 812 | 776 |
group_id=group_photo.group_id, |
| 813 | 777 |
photo_id=group_photo.pk, |
| 814 | 778 |
msg_type=UserMessageInfo.THUMBUP, |
@@ -821,7 +785,7 @@ def thumbup_submit_api(request): |
||
| 821 | 785 |
'message': u'点赞提交成功', |
| 822 | 786 |
'data': {
|
| 823 | 787 |
'thumbup': True, |
| 824 |
- 'thumbups': photo_thumbups, |
|
| 788 |
+ 'thumbups': get_group_photo_thumbup_list(photo_id), |
|
| 825 | 789 |
} |
| 826 | 790 |
}) |
| 827 | 791 |
|
@@ -4,10 +4,10 @@ import json |
||
| 4 | 4 |
|
| 5 | 5 |
from django.conf import settings |
| 6 | 6 |
|
| 7 |
-from group.models import GroupInfo, GroupPhotoInfo, GroupUserInfo |
|
| 7 |
+from group.models import GroupInfo, GroupPhotoInfo, GroupUserInfo, PhotoCommentInfo, PhotoThumbUpInfo |
|
| 8 | 8 |
from utils.redis.rgroup import set_group_photo_data, set_group_users_info |
| 9 |
-from utils.redis.rkeys import (GROUP_LAST_PHOTO_PK, GROUP_USERS_APPLYING_SET, GROUP_USERS_DELETED_SET, |
|
| 10 |
- GROUP_USERS_PASSED_SET, GROUP_USERS_REFUSED_SET) |
|
| 9 |
+from utils.redis.rkeys import (GROUP_LAST_PHOTO_PK, GROUP_PHOTO_WATCHER_SET, GROUP_USERS_APPLYING_SET, |
|
| 10 |
+ GROUP_USERS_DELETED_SET, GROUP_USERS_PASSED_SET, GROUP_USERS_REFUSED_SET) |
|
| 11 | 11 |
|
| 12 | 12 |
|
| 13 | 13 |
r = settings.REDIS_CACHE |
@@ -46,7 +46,19 @@ def retrieve_group_user_status(): |
||
| 46 | 46 |
r.sadd(GROUP_USERS_REFUSED_SET % group_id, user_id) |
| 47 | 47 |
|
| 48 | 48 |
|
| 49 |
+def retrieve_group_photo_watchers(): |
|
| 50 |
+ group_photos = GroupPhotoInfo.objects.filter(status=True) |
|
| 51 |
+ for group_photo in group_photos: |
|
| 52 |
+ photo_comments = PhotoCommentInfo.objects.filter(photo_id=group_photo.pk) |
|
| 53 |
+ for photo_comment in photo_comments: |
|
| 54 |
+ r.sadd(GROUP_PHOTO_WATCHER_SET % group_photo.pk, photo_comment.user_id) |
|
| 55 |
+ photo_thumbups = PhotoThumbUpInfo.objects.filter(photo_id=group_photo.pk) |
|
| 56 |
+ for photo_thumbup in photo_thumbups: |
|
| 57 |
+ r.sadd(GROUP_PHOTO_WATCHER_SET % group_photo.pk, photo_thumbup.user_id) |
|
| 58 |
+ |
|
| 59 |
+ |
|
| 49 | 60 |
def retrieve_redis_data(): |
| 50 | 61 |
retrieve_group_data() |
| 51 | 62 |
retrieve_last_pk() |
| 52 | 63 |
retrieve_group_user_status() |
| 64 |
+ retrieve_group_photo_watchers() |
@@ -6,7 +6,7 @@ from django.conf import settings |
||
| 6 | 6 |
from django.core.serializers.json import DjangoJSONEncoder |
| 7 | 7 |
|
| 8 | 8 |
from utils.redis.rkeys import (GROUP_INFO, GROUP_PHOTO_COMMENT_LIST, GROUP_PHOTO_DATA, GROUP_PHOTO_THUMB_UP, |
| 9 |
- GROUP_PHOTO_THUMB_UP_LIST, GROUP_USERS_INFO) |
|
| 9 |
+ GROUP_PHOTO_THUMB_UP_LIST, GROUP_PHOTO_WATCHER_SET, GROUP_USERS_INFO) |
|
| 10 | 10 |
|
| 11 | 11 |
|
| 12 | 12 |
r = settings.REDIS_CACHE |
@@ -135,3 +135,8 @@ def set_group_photo_thumbup_list(photo_id): |
||
| 135 | 135 |
def get_group_photo_thumbup_list(photo_id): |
| 136 | 136 |
""" 获取群组照片用户点赞列表 """ |
| 137 | 137 |
return json.loads(r.get(GROUP_PHOTO_THUMB_UP_LIST % photo_id) or '[]') or set_group_photo_thumbup_list(photo_id) |
| 138 |
+ |
|
| 139 |
+ |
|
| 140 |
+def get_group_photo_watchers(photo_id): |
|
| 141 |
+ """ 获取群组照片用户关注列表 """ |
|
| 142 |
+ return r.smembers(GROUP_PHOTO_WATCHER_SET % photo_id) |
@@ -19,6 +19,7 @@ GROUP_PHOTO_DATA = 'group:photo:data:%s' # STRING,群组数据记录,photo_ |
||
| 19 | 19 |
GROUP_PHOTO_THUMB_UP = 'group:photo:thumb:up:%s:%s' # STRING,群组照片用户点赞记录,photo_id、user_id |
| 20 | 20 |
GROUP_PHOTO_COMMENT_LIST = 'group:photo:comment:list:%s' # STRING,群组照片用户评论列表,photo_id |
| 21 | 21 |
GROUP_PHOTO_THUMB_UP_LIST = 'group:photo:thumb:up:list:%s' # STRING,群组照片用户点赞列表,photo_id |
| 22 |
+GROUP_PHOTO_WATCHER_SET = 'group:photo:watcher:set:%s' # SET,群组照片用户关注集合,photo_id,关注即评论点赞 |
|
| 22 | 23 |
GROUP_LAST_PHOTO_PK = 'group:last:photo:pk:%s' # STRING,群组最后一张照片PK,group_id |
| 23 | 24 |
|
| 24 | 25 |
# 摄影师照片相关 |