Nuril Maknun began recording the lewd phone calls from her boss. (Representational)

Nuril Maknun was tired of getting lewd phone calls from her boss, who she alleged repeatedly shared explicit details of his sexual encounters with her and demanded she engage in an affair.

So she began recording his calls.

Her lawyer said she did so for her own protection. But Indonesia's top court ruled this week that she's the one who should be punished, arguing that sharing the recordings amounted to the distribution of indecent material. The decision came as a major blow to women's rights advocates there, who said the court is blaming a victim of harassment while the man who allegedly harassed her will walk free.

"We are concerned about the impact of this decision because it opens a door for perpetrators of sexual violence to criminalize victims," Ade Wahyudin, head of Legal Aid Foundation for the Press, told Reuters.

The final ruling came after a yearslong legal battle, which began in 2015 when Maknun's boss, who goes by only one name, Muslim, found out about the recording and reported her to police. He claimed that sharing his comments amounted to defamation.

The two worked together at Senior High School Seven in Mataram, on Indonesia's Lombok island, where Maknun was a bookkeeper and Muslim was the principal.

Reuters reported that court documents show that Maknun said she began receiving the calls from Muslim as early as 2012, and later shared some recordings with a third party and distributed them on an electronic device. The New York Times reported that she says she played the recording for her husband and a teacher at the school to disprove a rumor spreading that the two were having an affair.

She has denied that she ever distributed the recording, saying that another teacher downloaded it from her phone while she was not in the room, the Times reported.

Maknun previously spent a month in jail during the investigation. Although she was originally acquitted, prosecutors then filed an appeal. That's when a panel of three judges sentenced her to six months in prison and ordered her to pay a fine of around $35,000. She fought the verdict, bringing the case all the way to the Supreme Court, where another panel of judges denied her request for it to be reviewed. Her jail term could be extended further if her family is unable to raise funds to pay the fine.

"I, as a woman, should be protected, but then I was the one who became the victim," she told the Times. "People should know that when we get harassed, there is no place to take refuge."

Her only hope for a reprieve will now have to come from Indonesia's highest office, but the chances of that remain murky under the country's clemency laws.

Last year, President Joko Widodo urged Maknun to seek a judicial review, saying that "if later she does not find justice . . . she can request clemency to the president."

"When the clemency request has been submitted," he said, "then it will be on my turf."

But Aziz Fauzi, one of Maknun's lawyers, told Reuters this week that her jail term is not long enough to qualify for clemency, so amnesty from the president is now the only option left "because we have exhausted all other legal avenues."

Widodo is apparently still following the case. On Friday, he told reporters that his "attention to this case has never diminished."

"If it gets to me, then it will be under my authority, and I will use the authority I have," he said.

Human rights groups have documented widespread discrimination against women in Indonesia, where in April, thousands of women took to the streets of Jakarta to call for equal rights and protest what they said were a raft of discriminatory laws.

Globally, women still face extreme punishment for reporting sexual harassment. In Bangladesh earlier this year, Nusrat Jahan Rafi, 19, was burned to death at her school after telling police her headmaster had fondled her. In February, Maryam Awaisu, a women's rights advocate in northern Nigeria was arrested in what Amnesty International said appeared to be "an attempt to intimidate and harass both her and other women supporting #ArewaMeToo - a movement seeking justice for victims of sexual violence in Nigeria."