Bug 1494584 - show other users on IMAP folder sharing tab. r=mkmelin
authorPing Chen <remotenonsense@gmail.com>
Thu, 28 May 2020 19:03:58 +0300
changeset 39261 21be6632c2745dd08dc9e2ecd6b36ced088aa061
parent 39260 ec0e99a2f1e46d0a1a0bd19fba4c71537ef23f5a
child 39262 1897e9e2fecbcbbeb759c1514643f10ccc018eae
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersmkmelin
bugs1494584
Bug 1494584 - show other users on IMAP folder sharing tab. r=mkmelin
mail/locales/en-US/chrome/messenger/folderProps.dtd
mailnews/base/content/folderProps.js
mailnews/base/content/folderProps.xhtml
mailnews/imap/src/nsImapMailFolder.cpp
--- a/mail/locales/en-US/chrome/messenger/folderProps.dtd
+++ b/mail/locales/en-US/chrome/messenger/folderProps.dtd
@@ -54,16 +54,17 @@
 <!ENTITY folderProps.reset.tooltip               "Restore default color">
 <!ENTITY folderProps.location.label              "Location:">
 <!ENTITY folderProps.location.accesskey          "L">
 
 <!ENTITY folderSharingTab.label                  "Sharing">
 <!ENTITY privileges.button.label                 "Privileges…">
 <!ENTITY privileges.button.accesskey             "P">
 <!ENTITY permissionsDesc.label                   "You have the following permissions:">
+<!ENTITY folderOtherUsers.label                  "Others with access to this folder:">
 <!ENTITY folderType.label                        "Folder Type:">
 
 <!ENTITY folderQuotaTab.label                    "Quota">
 <!ENTITY folderQuotaUsage.label                  "Usage:">
 <!ENTITY folderQuotaStatus.label                 "Status:">
 
 <!ENTITY numberOfMessages.label                  "Number of messages:">
 <!-- LOCALIZATION NOTE: When the number of messages can't be determined, this string is displayed as the number -->
--- a/mailnews/base/content/folderProps.js
+++ b/mailnews/base/content/folderProps.js
@@ -348,16 +348,24 @@ function folderPropsOnLoad() {
     }
   }
 
   if (serverType == "imap") {
     var imapFolder = gMsgFolder.QueryInterface(Ci.nsIMsgImapMailFolder);
     if (imapFolder) {
       imapFolder.fillInFolderProps(gFolderPropsSink);
     }
+
+    let users = [...imapFolder.getOtherUsersWithAccess()];
+    if (users.length) {
+      document.getElementById("folderOtherUsers").hidden = false;
+      document.getElementById("folderOtherUsersText").textContent = users.join(
+        ", "
+      );
+    }
   }
 
   var retentionSettings = gMsgFolder.retentionSettings;
   initCommonRetentionSettings(retentionSettings);
   document.getElementById("retention.useDefault").checked =
     retentionSettings.useServerDefaults;
 
   // set folder sizes
--- a/mailnews/base/content/folderProps.xhtml
+++ b/mailnews/base/content/folderProps.xhtml
@@ -180,16 +180,21 @@
       </hbox>
       <vbox align="start">
         <label value="" id="folderDescription.text"/>
         <label value=" "/>
         <label value="&permissionsDesc.label;" id="permissionsDescLabel"/>
 
         <description id="folderPermissions.text"></description>
       </vbox>
+      <vbox id="folderOtherUsers" align="start" hidden="true">
+        <label value=" "/>
+        <label value="&folderOtherUsers.label;"/>
+        <description id="folderOtherUsersText"></description>
+      </vbox>
       <spacer flex="100%"/>
       <vbox align="start">
         <button hidefor="movemail,pop3,none,rss,nntp" label="&privileges.button.label;"
                 oncommand="onFolderPrivileges();" accesskey="&privileges.button.accesskey;"
                 id="imap.FolderPrivileges" orient="right"/>
       </vbox>
     </vbox>
 
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -5923,19 +5923,27 @@ bool nsMsgIMAPFolderACL::SetFolderRights
 }
 
 NS_IMETHODIMP nsImapMailFolder::GetOtherUsersWithAccess(
     nsIUTF8StringEnumerator **aResult) {
   return GetFolderACL()->GetOtherUsers(aResult);
 }
 
 nsresult nsMsgIMAPFolderACL::GetOtherUsers(nsIUTF8StringEnumerator **aResult) {
+  nsCString myUserName;
+  nsCOMPtr<nsIMsgIncomingServer> server;
+  nsresult rv = m_folder->GetServer(getter_AddRefs(server));
+  NS_ENSURE_SUCCESS(rv, rv);
+  server->GetRealUsername(myUserName);
+
+  // We need to filter out myUserName from m_rightsHash.
   nsTArray<nsCString> *resultArray = new nsTArray<nsCString>;
   for (auto iter = m_rightsHash.Iter(); !iter.Done(); iter.Next()) {
-    resultArray->AppendElement(iter.Key());
+    if (!iter.Key().Equals(myUserName))
+      resultArray->AppendElement(iter.Key());
   }
 
   // enumerator will free resultArray
   return NS_NewAdoptingUTF8StringEnumerator(aResult, resultArray);
 }
 
 nsresult nsImapMailFolder::GetPermissionsForUser(const nsACString &otherUser,
                                                  nsACString &aResult) {