Updated

A man imprisoned for stalking has had his conviction overturned after North Carolina's Court of Appeals ruled the social media posts underpinning the charges were protected by free speech rights.

A three-judge panel ruled Tuesday for Brady Lorenzo Shackelford, who was sentenced to more than two years for stalking a woman he met at church in 2015. Court documents say Shackelford repeatedly called her his "soul mate" and future wife in Google Plus posts. He also sent handwritten letters and cupcakes, despite her turning down a dinner invitation, according to court documents.

The ruling says Shackelford's conviction was primarily based on social media posts, and thus violated his First Amendment rights.

The attorney general's office didn't immediately respond to a message asking if it will appeal to keep Shackelford imprisoned.