def send_message(): # Handles sending a message to a specific user. # create a message field in the db. message = request.form.get('message') current_user_id = session['user_id'] posting_user = request.form.get('posting_user') Message.add_message(current_user_id, posting_user, message) # Send an alert via sms to the posting # user that someone is interested in their food. food_listing_id = request.form.get('food_listing') food_listing = Food.query.get(food_listing_id) poster_name = food_listing.user.fname phone_number = food_listing.phone_number if phone_number: phone_number = "+1"+phone_number send_text(phone_number, ("Hi, %s! Someone's interested in your post " + "on Make Less Mush! Sign in and check your " + "messages!") % (poster_name)) flash('Your message has been sent.') return redirect('/home')
def send_sms_message(): # Send an sms to a user about their listing. number = request.form.get('number') message = request.form.get('message') send_text(number, message) return "Message sent"