def post_message(request, party_id): redis = StrictRedis(connection_pool=redis_connection_pool) message_type = request.POST.get('messageType') user = User.from_request(redis, request) party = Party.get(redis, party_id) m = Message.for_party(redis, party) if message_type == 'chat': text = request.POST.get('text') m.text = text if message_type == 'favorite': track = request.POST.get('trackKey') m.track = track if message_type == 'vote_to_skip': track = request.POST.get('trackKey') m.track = track m.user_id = user.id m.message_type = message_type m.save(redis) party.broadcast_message_added(redis, m) return HttpResponse(status=httplib.CREATED)
def messages(request, party_id): redis = StrictRedis(connection_pool=redis_connection_pool) if request.method == "POST": post_message(request, party_id) messages = Message.get_recent(redis, party_id) dict_messages = [ message.to_dict() for message in messages ] return JsonResponse({'results': dict_messages})
def send_play_track_message(self, rdio_track_key): message = Message.make_now_playing_message(self.redis, self.party, rdio_track_key) message.save(self.redis) self.party.broadcast_message_added(self.redis, message)