Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

trying to disable attachment notification

Sergio _
Contributor
March 28, 2022

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
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2022

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

Sergio _
Contributor
March 28, 2022 edited

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 

Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2022

That should be it.

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

Sergio _
Contributor
March 28, 2022

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

Sergio _
Contributor
March 28, 2022
<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
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2022

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
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2022

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

Sergio _
Contributor
March 28, 2022

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

regards.

Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 28, 2022

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

Sergio _
Contributor
March 28, 2022

thanks Thiago for your help. 

0 votes
Sergio _
Contributor
June 10, 2022

@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
AUG Leaders

Atlassian Community Events