@@ -1,15 +1,5 @@
|
||||
import { IActor } from "@/types/actor";
|
||||
|
||||
function autoUpdateUsername(actor: IActor, newDisplayName: string | null): IActor {
|
||||
const oldUsername = convertToUsername(actor.name);
|
||||
|
||||
if (actor.preferredUsername === oldUsername) {
|
||||
actor.preferredUsername = convertToUsername(newDisplayName);
|
||||
}
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
function convertToUsername(value: string | null): string {
|
||||
if (!value) return "";
|
||||
|
||||
@@ -22,6 +12,17 @@ function convertToUsername(value: string | null): string {
|
||||
.replace(/[^a-z0-9_]/g, "");
|
||||
}
|
||||
|
||||
function autoUpdateUsername(actor: IActor, newDisplayName: string | null): IActor {
|
||||
const actor2 = { ...actor };
|
||||
const oldUsername = convertToUsername(actor.name);
|
||||
|
||||
if (actor.preferredUsername === oldUsername) {
|
||||
actor2.preferredUsername = convertToUsername(newDisplayName);
|
||||
}
|
||||
|
||||
return actor2;
|
||||
}
|
||||
|
||||
function validateUsername(actor: IActor): boolean {
|
||||
return actor.preferredUsername === convertToUsername(actor.preferredUsername);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user