It’s a happy week for the people of Latvia. They are celebrating the 25th anniversary of their independence from the Soviet Union, which was declared on 4 May 1990.

That date signalled the lifting of decades of Soviet-style censorship and totalitarianism. So it is fitting that this year the capital, Riga, also played host to United Nations World Press Freedom Day on 3 May with a series of events.

But there was an alarming message from this Press Freedom Day: big brother is watching you – again.

The World Association of Newspapers and News Publishers (WAN-IFRA) previewed its forthcoming global study of shield laws on the protection of confidential sources. Its top line is “Just assume that you are being watched!” That new reality was acknowledged at the Riga meeting of 500 journalists, NGO representatives and UN officials.

It is the mass or ‘bulk’ surveillance done by the NSA and GCHQ, as revealed by Edward Snowden. And it’s states like Syria using advanced spy software – often bought from companies in Europe – to track down, jail and torture journalists and dissidents.

It’s also Isis hacking into the French public TV network TV5Monde, and cyber-attacks by a Tunisian Islamist group against Le Soir newspaper in Belgium and a regional government website in order to demand an end to US-led military action in the Middle East.

It is the mass storage of metadata, and internet companies being forced to hand over huge amounts of private user information to governments around the world.

And it is electronic armies, trolls threatening extreme violence, automatic geo-locators, take-down orders and destructive malicious software.

They all lead to fear and self-censorship, as journalists from around the world testified in Riga.

Larry Kilman, secretary-general of WAN-IFRA, said mass and targeted surveillance can make source protection laws “irrelevant”. Anti-terrorism and data retention laws often lead to journalists being prosecuted and forced to reveal their sources.

The advice to journalists and media everywhere? Practise extreme distrust. Rely on face-to-face meetings with news sources instead of emails. And invest heavily in digital security and legal advice.

There was finger-pointing at the UK, where it was revealed that the police had used the Regulations of Investigatory Powers Act (RIPA) 19 times over three years to seek data including phone records in relation to 34 investigations involving journalists.

The UK’s interception commissioner Sir Anthony May said in February that current rules “do not provide adequate safeguards to protect journalistic sources or prevent unnecessary or disproportionate intrusions”.

It’s a fast-moving area of the law. In many European countries improved safeguards for journalists and whistle-blowers are promised or under way. But David Kaye, UN special rapporteur (senior non-government expert) on freedom of expression challenged governments to change their behaviour to meet their obligations in international law. Too often, he said, they have used national security or public order as a pretext to impose disproportionate and intrusive rules secretly.

“Online surveillance is a direct threat to media, NGOs, academics and activists,” Kaye said; governments should act to protect privacy and allow encryption and anonymity.

In the heady days of the ‘Arab Spring’ the internet was a great tool for both journalists and activists. Now, as Maryam Al-Khawaja of the Gulf Centre for Human Rights said, the internet is used as a tool of repression – especially in places like Bahrain where the government mostly owns the media.

“It’s a new arms race,” according to Courtney Radsch of the Committee to Protect Journalists. CPJ says revelations about mass surveillance spell the end of privacy online, and that has diminished the power to hold governments accountable.

All journalists now need to use encryption systems as a matter of course, Radsch said, to protect themselves and their news sources.

This World Press Freedom Day was held in the dark shadow of the murders of the Charlie Hebdo journalists and cartoonists as well as the execution-style killings of journalists by Isis in Syria.

Unesco publicly condemns every killing of a journalist wherever it takes place. In the past seven years the death toll has reached 675. And in nine out of 10 of those cases those responsible are not brought to justice, so impunity reigns.

Hamid Mir, the Pakistani TV journalist and anchorman who survived an assassination attempt just a year ago, is a symbol of the determination to speak truth to power despite relentless intimidation. He took part in the Riga meetings with two of the six bullets fired at him by the would-be assassins still in his body.

And Peter Greste spoke of his astonishment and gratitude at the extraordinary global campaign for his release and that of his al-Jazeera colleagues Mohamed Fahmy and Baher Mohamed. They were detained in December 2013 and tried on charges of false reporting and aiding a terrorist organisation, for which no evidence was produced.

Incredibly, the hashtag #FreeAJStaff got three billion impressions during his 13 months in Egyptian jails, before Greste was released on 1 February this year.

Fahmy and Mohamed are currently free pending a retrial. The date of the next hearing has been set as 9 May.

But Peter Greste said he found it disturbing that thousands of other cases of mainly local journalists who are routinely attacked, jailed, forcibly ‘disappeared’, tortured or killed go unreported in the media. Greste appealed to his media colleagues to get over what he called “the existential angst about reporting about ourselves”.

We need, he said, to stand behind the role of journalists in upholding democracy. When so many cases go unreported the public often fails to understand the essential role played by journalists, and then governments often get away with attacks on the press.

Unesco is the lead UN agency coordinating the UN Plan of Action on the Safety of Journalists and the Issue of Impunity.

At the Riga conference four UN rapporteurs on freedom of expression issued a Joint Declaration on Freedom of Expression and Responses to Conflict Situations.