def get(self): parser = reqparse.RequestParser() parser.add_argument("x-access-token", location='headers', required=True, help='Missing user token!') args_dict = parser.parse_args() id = AuthSender.get_uuid_from_token(args_dict["x-access-token"]) self.logger.info( f"Returning push token for user {id}. RESPONSECODE:200") return {"push_token": UsersDAO.get_tkn(id)}, 200
def send_notification(cls, user_id, title, subtitle, message_type, extra_data): cls.logger().info(f"send_notification: Sending to user {user_id}. Title: {title}. Subtitle: {subtitle}. MsgType: {message_type}. ExtraData: {extra_data}") token = UsersDAO.get_tkn(user_id) if not token: cls.logger().error(f"No token detected for user {user_id}. Unable to send push notification") return data = extra_data.copy() data["type"] = message_type cls.logger().info(f"send_notification: Valid token found, sending notification...") cls._make_push(user_id, token, title, subtitle, data)