A former police constable who hugged two women he had contact with while on duty and sent them inappropriate messages on social media has been jailed for 15 months.