                     slug = "sharing_update_notification"
                     createPersistentNotif apps[docType], slug, message, callback
 
-    # A shared document has been deleted by the sharer
+    # A shared document has been deleted by the sharer.
     else if tokens[2] is "delete"
-        # The doc id and the shareID are concatenated
+        # The doc id and the shareID are concatenated.
         [id, shareID] = extractIds id
 
         if id? and shareID?
             getSharingInfos id, shareID, (err, sharing, docType) ->
                 if err?
                     log.error err
-                # The sharer shouldn't be notified as he created the request
+                # The sharer shouldn't be notified as he created the request.
                 else if not sharing.targets? and docType?
                     sharerName = sharing.sharerName
                     article = articleBeforeDocType docType


    # Get the sharing doc
    clientDS.post path, options, (err, result, body) ->
        doc = body[0]?.doc
        docType = extractDocType doc.rules, id
        callback err, doc, docType


# Called after a sharing event published by the Data-System
# 3 cases must be handled on the recipient side :
# a sharing request creation, an updated shared doc and a deleted shared doc.
module.exports.handleNotification = (event, id, callback) ->
    # Split the published event
    tokens = event.split "."

    # A new sharing request has been received
    if tokens[1] is "create"
        Sharing.find id, (err, sharing) ->
            if err?
                log.error err
            # The sharer shouldn't be notified as he created the request
            else if not sharing.targets?
                docType = sharing.rules[0].docType
                article = articleBeforeDocType docType
                messageKey = 'sharing create request notification'

                        docType: docType
                createTemporaryNotif apps[docType], message, callback

    # A shared document has been updated by the sharer.
    else if tokens[2] is "update"
        # The doc id and the shareID are concatenated.
        [id, shareID] = extractIds id

        if id? and shareID?
            getSharingInfos id, shareID, (err, sharing, docType) ->
                if err?
                    log.error err
                # The sharer shouldn't be notified as he created the request.
                else if not sharing.targets? and docType?
                    sharerName = sharing.sharerName
                    article = articleBeforeDocType docType
