Files
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

26 lines
1.1 KiB
TypeScript

/**
* How to name whoever performed a logged action.
*
* Four renderers were each carrying their own copy of this, which is how
* an unauthenticated visitor came to be shown as "System" in all of them:
* one word covering both the scheduler and a stranger leaving a comment,
* so the audit trail read as though the installation had commented on its
* own file.
*
* Returns a translation key, not a translated string — the caller holds
* the `t` from its own component.
*/
export function activityActorLabel(entry: { actor_name: string | null; actor_type: string | null; origin?: string }): {
kind: 'named' | 'anonymous' | 'system' | 'deleted';
key: string;
} {
if (entry.actor_name !== null) return { kind: 'named', key: entry.actor_name };
// A name is missing for three different reasons, and they are not
// interchangeable: nobody was signed in, nothing human was involved at
// all, or the account has since been erased.
if (entry.actor_type !== null) return { kind: 'deleted', key: 'Deleted account' };
return entry.origin === 'public' ? { kind: 'anonymous', key: 'Anonymous' } : { kind: 'system', key: 'System' };
}