Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33258764
D9061.1768593726.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D9061.1768593726.diff
View Options
diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js
--- a/keyserver/src/updaters/thread-updaters.js
+++ b/keyserver/src/updaters/thread-updaters.js
@@ -8,7 +8,6 @@
roleIsAdminRole,
viewerIsMember,
getThreadTypeParentRequirement,
- validChatNameRegex,
} from 'lib/shared/thread-utils.js';
import type { Shape } from 'lib/types/core.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
@@ -31,6 +30,7 @@
import { ServerError } from 'lib/utils/errors.js';
import { promiseAll } from 'lib/utils/promises.js';
import { firstLine } from 'lib/utils/string-utils.js';
+import { validChatNameRegex } from 'lib/utils/validation-utils.js';
import { reportLinkUsage } from './link-updaters.js';
import { updateRoles } from './role-updaters.js';
diff --git a/lib/shared/mention-utils.js b/lib/shared/mention-utils.js
--- a/lib/shared/mention-utils.js
+++ b/lib/shared/mention-utils.js
@@ -2,7 +2,7 @@
import { oldValidUsernameRegexString } from './account-utils.js';
import SentencePrefixSearchIndex from './sentence-prefix-search-index.js';
-import { threadOtherMembers, chatNameMaxLength } from './thread-utils.js';
+import { threadOtherMembers } from './thread-utils.js';
import { stringForUserExplicit } from './user-utils.js';
import { threadTypes } from '../types/thread-types-enum.js';
import type {
@@ -11,7 +11,7 @@
ResolvedThreadInfo,
ChatMentionCandidates,
} from '../types/thread-types.js';
-import { idSchemaRegex } from '../utils/validation-utils.js';
+import { idSchemaRegex, chatNameMaxLength } from '../utils/validation-utils.js';
export type TypeaheadMatchedStrings = {
+textBeforeAtSymbol: string,
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -111,12 +111,6 @@
import { trimText } from '../utils/text-utils.js';
import { pendingThreadIDRegex } from '../utils/validation-utils.js';
-const chatNameMaxLength = 191;
-const chatNameMinLength = 0;
-const secondCharRange = `{${chatNameMinLength},${chatNameMaxLength}}`;
-const validChatNameRegexString = `.${secondCharRange}`;
-const validChatNameRegex: RegExp = new RegExp(`^${validChatNameRegexString}$`);
-
function threadHasPermission(
threadInfo: ?(ThreadInfo | RawThreadInfo),
permission: ThreadPermission,
@@ -1960,9 +1954,6 @@
switchMemberAdminRoleInThread,
getAvailableThreadMemberActions,
threadMembersWithoutAddedAshoat,
- validChatNameRegex,
- validChatNameRegexString,
- chatNameMaxLength,
patchThreadInfoToIncludeMentionedMembersOfParent,
threadInfoInsideCommunity,
useRoleMemberCountsForCommunity,
diff --git a/lib/utils/validation-utils.js b/lib/utils/validation-utils.js
--- a/lib/utils/validation-utils.js
+++ b/lib/utils/validation-utils.js
@@ -107,6 +107,12 @@
const pendingThreadIDRegex = `pending/(type[0-9]+/[0-9]+(\\+[0-9]+)*|sidebar/${idSchemaRegex})`;
+const chatNameMaxLength = 191;
+const chatNameMinLength = 0;
+const secondCharRange = `{${chatNameMinLength},${chatNameMaxLength}}`;
+const validChatNameRegexString = `.${secondCharRange}`;
+const validChatNameRegex: RegExp = new RegExp(`^${validChatNameRegexString}$`);
+
export {
tBool,
tString,
@@ -132,4 +138,7 @@
ashoatKeyserverID,
idSchemaRegex,
pendingThreadIDRegex,
+ validChatNameRegex,
+ validChatNameRegexString,
+ chatNameMaxLength,
};
diff --git a/native/chat/settings/thread-settings-name.react.js b/native/chat/settings/thread-settings-name.react.js
--- a/native/chat/settings/thread-settings-name.react.js
+++ b/native/chat/settings/thread-settings-name.react.js
@@ -14,7 +14,6 @@
changeThreadSettings,
} from 'lib/actions/thread-actions.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
-import { chatNameMaxLength } from 'lib/shared/thread-utils.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import {
type ResolvedThreadInfo,
@@ -27,6 +26,7 @@
useDispatchActionPromise,
} from 'lib/utils/action-utils.js';
import { firstLine } from 'lib/utils/string-utils.js';
+import { chatNameMaxLength } from 'lib/utils/validation-utils.js';
import SaveSettingButton from './save-setting-button.react.js';
import EditSettingButton from '../../components/edit-setting-button.react.js';
diff --git a/native/utils/typeahead-utils.js b/native/utils/typeahead-utils.js
--- a/native/utils/typeahead-utils.js
+++ b/native/utils/typeahead-utils.js
@@ -9,8 +9,8 @@
type TypeaheadTooltipActionItem,
type MentionTypeaheadSuggestionItem,
} from 'lib/shared/mention-utils.js';
-import { validChatNameRegexString } from 'lib/shared/thread-utils.js';
import { stringForUserExplicit } from 'lib/shared/user-utils.js';
+import { validChatNameRegexString } from 'lib/utils/validation-utils.js';
// Native regex is a little bit different than web one as
// there are no named capturing groups yet on native.
diff --git a/web/modals/threads/settings/thread-settings-general-tab.react.js b/web/modals/threads/settings/thread-settings-general-tab.react.js
--- a/web/modals/threads/settings/thread-settings-general-tab.react.js
+++ b/web/modals/threads/settings/thread-settings-general-tab.react.js
@@ -7,10 +7,7 @@
changeThreadSettingsActionTypes,
changeThreadSettings,
} from 'lib/actions/thread-actions.js';
-import {
- threadHasPermission,
- chatNameMaxLength,
-} from 'lib/shared/thread-utils.js';
+import { threadHasPermission } from 'lib/shared/thread-utils.js';
import { type SetState } from 'lib/types/hook-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import { type ThreadInfo, type ThreadChanges } from 'lib/types/thread-types.js';
@@ -19,6 +16,7 @@
useServerCall,
} from 'lib/utils/action-utils.js';
import { firstLine } from 'lib/utils/string-utils.js';
+import { chatNameMaxLength } from 'lib/utils/validation-utils.js';
import SubmitSection from './submit-section.react.js';
import css from './thread-settings-general-tab.css';
diff --git a/web/utils/typeahead-utils.js b/web/utils/typeahead-utils.js
--- a/web/utils/typeahead-utils.js
+++ b/web/utils/typeahead-utils.js
@@ -9,9 +9,9 @@
type TypeaheadTooltipActionItem,
getRawChatMention,
} from 'lib/shared/mention-utils.js';
-import { validChatNameRegexString } from 'lib/shared/thread-utils.js';
import { stringForUserExplicit } from 'lib/shared/user-utils.js';
import type { SetState } from 'lib/types/hook-types.js';
+import { validChatNameRegexString } from 'lib/utils/validation-utils.js';
import ThreadAvatar from '../avatars/thread-avatar.react.js';
import UserAvatar from '../avatars/user-avatar.react.js';
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 16, 8:02 PM (11 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5945827
Default Alt Text
D9061.1768593726.diff (6 KB)
Attached To
Mode
D9061: [lib][native][web] Move validChatNameRegex to validation-utils.js
Attached
Detach File
Event Timeline
Log In to Comment