The U.S. Supreme Court on Thursday barred a proposed class action lawsuit accusing Facebook Inc of violating a federal anti-robocall law, sparing the social media company from a potentially costly fight over unwanted text messages.

The justices, in a 9-0 decision authored by Justice Sonia Sotomayor, sided with Facebook in its appeal of a lower court ruling that revived the lawsuit alleging that the text messages violated the Telephone Consumer Protection Act. That 1991 federal law sought to curb telemarketing abuse by banning most unauthorized robocalls.

The court ruled that Facebook’s actions – sending text messages without consent – did not fit within the technical definition of the type of conduct barred by the law, which was enacted before the rise of modern cellphone technology.

The lawsuit was filed in 2015 in California federal court by Montana resident Noah Duguid, who said Facebook sent him many automatic text messages without his consent. The lawsuit accused Menlo Park, California-based Facebook of violating the Telephone Consumer Protection Act’s restriction on using an automatic telephone dialing system.

“As the court recognized, the law’s provisions were never intended to prohibit companies from sending targeted security notifications and the court’s decision will allow companies to continue working to keep the accounts of their users safe,” Facebook said in a statement.

The case highlighted the challenge for the justices in applying outdated laws to modern technologies. In this instance, the lawsuit asserted that Facebook’s system that sent automated text messages was akin to a traditional automatic dialing system – known as an autodialer – used to send robocalls.

“Duguid’s quarrel is with Congress, which did not define an autodialer as malleably as he would have liked,” Sotomayor wrote.

The law requires that the equipment used must use a “random or sequential number generator” but the court concluded that Facebook’s system “does not use such technology,” Sotomayor added.

Duguid said that Facebook repeatedly sent him account login notifications by text message to his cellphone even though he was not a Facebook user and never had been. Despite numerous efforts, Duguid said he was unable to stop Facebook from “robotexting” him.

Facebook responded that Duguid had most likely been assigned a phone number that had been previously associated with a Facebook user who had opted in to receive the notifications.

A federal judge threw out the lawsuit but in 2019 the San Francisco-based 9th U.S. Circuit Court of Appeals revived it. The appeals court took a broad view of the law, saying it not only bans devices that automatically dial randomly generated numbers but also stored numbers that are not randomly generated.

The National Association of Federally-Insured Credit Unions said the decision “to narrowly interpret autodialers is a win for the credit union industry.”

“We have long fought for this clarity to ensure credit unions can contact their members with important, time-sensitive financial information without fear of violating the TCPA (Telephone Consumer Protection Act) and facing frivolous lawsuits,” the association said in a statement.