Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,589
Community Members
 
Community Events
165
Community Groups

trying to disable attachment notification

according to this workarround.

https://confluence.atlassian.com/confkb/how-to-disable-notifications-for-attachments-action-862622270.html

I need to disable notifications when an attachments is uploaded in confluence.

I did a Groovy code to perform it.
But The response is allways 401

"subCode": "upm.websudo.error"

Tried with basic and bearer token autentificación


import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

URL url = new URL("MYCONFLUENCEURL/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key/modules/file-content-remove-notification-key");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("PUT");

httpConn.setRequestProperty("Content-Type", "application/vnd.atl.plugins.plugin.module+json");


httpConn.setRequestProperty("Authorization", "Bearer " + "MYTOKEN");

httpConn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
writer.write("{\n \"enabled\": false\n}");
writer.flush();
writer.close();
httpConn.getOutputStream().close();

InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
log.warn(response);





Regards,

2 answers

1 accepted

0 votes
Answer accepted

Hi @Sergio _ 

You may need to temporarily disable the websudo feature while running that script.

Is this an option to your use case?

Kind regards,
Thiago Masutti

Hi thiago. It is working disable the sudo option.

Do you know how to do a rollback?


I tried 

writer.write("{\n \"enabled\": true\n}");

but it is not working

Thanks 

That should be it.

What is the output you get when trying to enable it?

2022-03-28 17:13:00,528 WARN [runner.ScriptBindingsManager]: 500

<status>
    <status-code>500</status-code>
    <message>The module class cannot be determined, likely because it needs a concrete module type defined in the generic type it passes to AbstractModuleDescriptor</message>
    <stack-trace>java.lang.IllegalStateException: The module class cannot be determined, likely because it needs a concrete module type defined in the generic type it passes to AbstractModuleDescriptor

Yeah, I got the same problem when trying to enable that module. Seems like you can't simply re-enable it.

I was able to revert it by disabling the full App and then enabling it again.

 

--- disable system App

curl -vvv -k -L -X PUT \
-H
'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
${CONFLUENCE_BASE_URL}
'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
-d
'{ "enabled": false }'

--- enable system App

curl -vvv -k -L -X PUT \
-H
'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
${CONFLUENCE_BASE_URL}
'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
-d
'{ "enabled": true }'

While testing I couldn't find any other consequences on this action, but I would strongly checking that on your lower instance first.
Kind regards,
Thiago Masutti

Sergio.

In regards to your original issue with websudo, I've created a new bug as I understand this should bypass the websudo requirement when using PAT.

UPM-6129 -- When websudo is enabled then UPM REST API fails with 401 Unauthorized response when authenticating with personal access token

Kind regards,
Thiago Masutti

Sorry for my low knowledge. What do you mean about disable/enabled full system app?

regards.

Hi Sergio.

That means you should disable and then enable the entire Plugin (Confluence File Notification) instead of just trying to enable the module.

You may try the following API calls to accomplish that.

--- disable system App

curl -vvv -k -L -X PUT \
-H
'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
${CONFLUENCE_BASE_URL}
'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
-d
'{ "enabled": false }'

--- enable system App

curl -vvv -k -L -X PUT \
-H
'Content-Type: application/vnd.atl.plugins.plugin+json' -u admin:admin \
${CONFLUENCE_BASE_URL}
'/rest/plugins/1.0/com.atlassian.confluence.plugins.confluence-file-notifications-key' \
-d
'{ "enabled": true }'

 

Kind regards,
Thiago Masutti

thanks Thiago for your help. 

@Thiago Masutti 

what about versioning notifications.  I need to disable those notifications too.

Can I do the same disabling  file-notifications-file-details-file-version module?

Regards.


Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

282 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you