In this page

Notification emails

Visually indicating missing users (left employees)

In large teams, it might come in handy to see if users in the notification emails are not available anymore. For example, the following notification email code snippet displays a red "employee left" marker if the author the page is not a valid Confluence user anymore:

## this is the main iteration over the pages
#foreach($page in $pagesInSpace)
	<div class="page-item">
		## ...
		(author =
				<span style="color:red">EMPLOYEE LEFT</span>

Implementing the "Permanently Delete" strategy

When pages are archived using the Trash strategy, they are not deleted permanently, but "logically" by being moved to the Confluence trash. This is a safe operation, since these pages can be easily restored from the trash if needed.

In other use cases, "archiving" should permanently delete pages to save disk space, to keep the database clean or to comply with security requirements. There is no built-in strategy which implements this behavior, because permanently deleted content can only be restored from Confluence backups, which would make this strategy very dangerous.

Nevertheless, it is possible to implement a strategy like that by using the Trash strategy combined with periodically purging the trash! Consider these two options for the second part:

  1. Use the Auto Purge Trash app. It's a free and lightweight app which addresses this specific problem. You can configure the retention time period and schedule the purging process using the scheduler provided by the app.
  2. Use the ScriptRunner for Confluence app and schedule a custom job with the following Groovy script:
    import org.apache.log4j.Logger
    import com.atlassian.sal.api.component.ComponentLocator
    import com.atlassian.confluence.spaces.Space
    import com.atlassian.confluence.spaces.SpaceManager
    import com.atlassian.confluence.pages.TrashManager
    def log = Logger.getLogger("TrashPurger")
    // configuration
    int retentionDays = 90
    def spaceManager = ComponentLocator.getComponent(SpaceManager)
    def trashManager = ComponentLocator.getComponent(TrashManager)
    for (Space space : spaceManager.getAllSpaces()) {"Purging trash in space <%s> with retentionDays <%d>", space.key, retentionDays))
    	try {
    		def trashPageContents = trashManager.getTrashContents(space, 0, trashManager.getNumberOfItemsInTrash(space))
    		Date today = new Date()
    		trashPageContents.each {
    			def contentId = it.contentId
    			def contentLastModified = it.lastModificationDate ?: (it.creationDate ?: null)
    			if (contentLastModified) {
    				Calendar cal = Calendar.getInstance()
    				cal.add(5, retentionDays)
    				def contentRetentionTime = cal.getTime()
    				if (contentRetentionTime.before(today)) {
    					log.debug(String.format("Deleting content with ID <%d>, last modified on <%tF>", contentId.asLong(), contentLastModified))
    					trashManager.purge(space.key, contentId.asLong())
    			} else {
    				log.debug(String.format("Unable to detect created/modified date for content with ID <%d>, skipping...", contentId.asLong()))
    	} catch (Exception ex) {
    		log.error(String.format("Failed to purge trash of space <%s>", space.key), ex)
    • The script permanently deletes all content from the trash of all spaces.
    • The retentionDays variable allows you to configure the minimum number of days that must elapse between the last update of the trashed page and the date the script was run for the page to be purged. As Confluence does not record the precise deletion date, the script checks the last update date (or if it is not available, the creation date) of the page.
    • ScriptRunner provides a built-in script called Bulk Purge Trash to purge the trash for one or all spaces. Unfortunately, it cannot be scheduled, so the administrator has to run it manually.


Ask us any time.