Example #1
0
def create_reply(post_id):
	current_user = g.user
	current_location = g.user_location

	body = request.form['reply-body']
	privacy = request.form['privacy']

	new_reply = post_service.create_new_reply(current_user, body, post_id, current_location, privacy)
	updated_post = post_service.get_post_by_id(current_user.user_id, post_id)

	notification_service.create_notification_for_user(updated_post.author_id, NotificationType.REPLIED, post_id, current_user.user_id)

	return { "error" : False, "reply" : new_reply.to_json_dict(), "updated_post" : updated_post.to_json_dict() }
Example #2
0
def create_like(post_id):
	current_user = g.user

	try:
		post_service.create_like(post_id, current_user.user_id)
	except DAOException as e:
		return {
			"error" : True
		}

	post = post_service.get_post_by_id(current_user.user_id, post_id) # We only get the post for the notification, consider not doing this
	notification_service.create_notification_for_user(post.author_id, NotificationType.LIKED, post_id, current_user.user_id)

	return { "error" : False }
	def test_get_post_by_id(self, get_post_by_id):
		post_service.get_post_by_id(1, 1)
		self.assertTrue(get_post_by_id.called)