schedulemessages: Add handle_deferred_message() to handle requests.

This is responsible for:
1.) Handling all the incoming requests at the
messages endpoint which have defer param set. This is similar to
send_message_backend apart from the fact that instead of really
sending a message it schedules one to be sent later on.
2.) Does some preliminary checks such as validating timestamp for
scheduling a message, prevent scheduling a message in past, ensure
correct format of message to be scheduled.
3.) Extracts time of scheduled delivery from message.
4.) Add tests for the newly introduced function.
5.) timezone: Add get_timezone() to obtain tz object from string.
This helps in obtaining a timezone (tz) object from a timezone
specified as a string. This string needs to be a pytz lib defined
timezone string which we use to specify local timezones of the
users.
This commit is contained in:
Aditya Bansal
2018-01-04 23:11:34 +05:30
committed by showell
parent 6b03e25382
commit f46d098558
3 changed files with 152 additions and 6 deletions

View File

@@ -5,3 +5,6 @@ import pytz
def get_all_timezones() -> List[Text]:
return sorted(pytz.all_timezones)
def get_timezone(tz: Text) -> pytz.datetime.tzinfo:
return pytz.timezone(tz)