Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32210861
D8639.1765133234.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
D8639.1765133234.diff
View Options
diff --git a/keyserver/src/endpoints.js b/keyserver/src/endpoints.js
--- a/keyserver/src/endpoints.js
+++ b/keyserver/src/endpoints.js
@@ -60,6 +60,7 @@
threadJoinResponder,
toggleMessagePinResponder,
roleModificationResponder,
+ roleDeletionResponder,
} from './responders/thread-responders.js';
import {
userSubscriptionUpdateResponder,
@@ -144,6 +145,10 @@
responder: entryDeletionResponder,
requiredPolicies: baseLegalPolicies,
},
+ delete_community_role: {
+ responder: roleDeletionResponder,
+ requiredPolicies: baseLegalPolicies,
+ },
delete_thread: {
responder: threadDeletionResponder,
requiredPolicies: baseLegalPolicies,
diff --git a/keyserver/src/responders/thread-responders.js b/keyserver/src/responders/thread-responders.js
--- a/keyserver/src/responders/thread-responders.js
+++ b/keyserver/src/responders/thread-responders.js
@@ -28,6 +28,8 @@
type ToggleMessagePinResult,
type RoleModificationRequest,
type RoleModificationResult,
+ type RoleDeletionRequest,
+ type RoleDeletionResult,
rawThreadInfoValidator,
} from 'lib/types/thread-types.js';
import { serverUpdateInfoValidator } from 'lib/types/update-types.js';
@@ -48,6 +50,7 @@
} from './entry-responders.js';
import { modifyRole } from '../creators/role-creator.js';
import { createThread } from '../creators/thread-creator.js';
+import { deleteRole } from '../deleters/role-deleters.js';
import { deleteThread } from '../deleters/thread-deleters.js';
import { fetchMediaForThread } from '../fetchers/upload-fetchers.js';
import type { Viewer } from '../session/viewer.js';
@@ -393,6 +396,36 @@
);
}
+const roleDeletionRequestInputValidator = tShape<RoleDeletionRequest>({
+ community: tID,
+ roleID: tID,
+});
+
+export const roleDeletionResultValidator: TInterface<RoleDeletionResult> =
+ tShape<RoleDeletionResult>({
+ threadInfo: t.maybe(rawThreadInfoValidator),
+ updatesResult: tShape({
+ newUpdates: t.list(serverUpdateInfoValidator),
+ }),
+ });
+
+async function roleDeletionResponder(
+ viewer: Viewer,
+ input: mixed,
+): Promise<RoleDeletionResult> {
+ const request = await validateInput(
+ viewer,
+ roleDeletionRequestInputValidator,
+ input,
+ );
+ const response = await deleteRole(viewer, request);
+ return validateOutput(
+ viewer.platformDetails,
+ roleDeletionResultValidator,
+ response,
+ );
+}
+
export {
threadDeletionResponder,
roleUpdateResponder,
@@ -405,4 +438,5 @@
newThreadRequestInputValidator,
toggleMessagePinResponder,
roleModificationResponder,
+ roleDeletionResponder,
};
diff --git a/lib/actions/thread-actions.js b/lib/actions/thread-actions.js
--- a/lib/actions/thread-actions.js
+++ b/lib/actions/thread-actions.js
@@ -16,6 +16,8 @@
ToggleMessagePinResult,
RoleModificationRequest,
RoleModificationPayload,
+ RoleDeletionRequest,
+ RoleDeletionPayload,
} from '../types/thread-types.js';
import type { CallServerEndpoint } from '../utils/call-server-endpoint.js';
import { values } from '../utils/objects.js';
@@ -212,6 +214,23 @@
};
};
+const deleteCommunityRoleActionTypes = Object.freeze({
+ started: 'DELETE_COMMUNITY_ROLE_STARTED',
+ success: 'DELETE_COMMUNITY_ROLE_SUCCESS',
+ failed: 'DELETE_COMMUNITY_ROLE_FAILED',
+});
+const deleteCommunityRole =
+ (
+ callServerEndpoint: CallServerEndpoint,
+ ): ((request: RoleDeletionRequest) => Promise<RoleDeletionPayload>) =>
+ async request => {
+ const response = await callServerEndpoint('delete_community_role', request);
+ return {
+ threadInfo: response.threadInfo,
+ updatesResult: response.updatesResult,
+ };
+ };
+
export {
deleteThreadActionTypes,
deleteThread,
@@ -232,4 +251,6 @@
toggleMessagePin,
modifyCommunityRoleActionTypes,
modifyCommunityRole,
+ deleteCommunityRoleActionTypes,
+ deleteCommunityRole,
};
diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js
--- a/lib/reducers/thread-reducer.js
+++ b/lib/reducers/thread-reducer.js
@@ -18,6 +18,7 @@
joinThreadActionTypes,
leaveThreadActionTypes,
modifyCommunityRoleActionTypes,
+ deleteCommunityRoleActionTypes,
} from '../actions/thread-actions.js';
import {
logOutActionTypes,
@@ -225,7 +226,8 @@
action.type === incrementalStateSyncActionType ||
action.type === processUpdatesActionType ||
action.type === newThreadActionTypes.success ||
- action.type === modifyCommunityRoleActionTypes.success
+ action.type === modifyCommunityRoleActionTypes.success ||
+ action.type === deleteCommunityRoleActionTypes.success
) {
const { newUpdates } = action.payload.updatesResult;
if (newUpdates.length === 0) {
diff --git a/lib/types/endpoints.js b/lib/types/endpoints.js
--- a/lib/types/endpoints.js
+++ b/lib/types/endpoints.js
@@ -57,6 +57,7 @@
CREATE_TEXT_MESSAGE: 'create_text_message',
CREATE_THREAD: 'create_thread',
DELETE_ENTRY: 'delete_entry',
+ DELETE_COMMUNITY_ROLE: 'delete_community_role',
DELETE_THREAD: 'delete_thread',
DELETE_UPLOAD: 'delete_upload',
DISABLE_INVITE_LINK: 'disable_invite_link',
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -109,6 +109,7 @@
ThreadJoinPayload,
ToggleMessagePinResult,
RoleModificationPayload,
+ RoleDeletionPayload,
} from './thread-types.js';
import type { ClientUpdatesResultWithUserInfos } from './update-types.js';
import type { CurrentUserInfo, UserStore } from './user-types.js';
@@ -1185,6 +1186,22 @@
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'DELETE_COMMUNITY_ROLE_STARTED',
+ +loadingInfo?: LoadingInfo,
+ +payload?: void,
+ }
+ | {
+ +type: 'DELETE_COMMUNITY_ROLE_SUCCESS',
+ +payload: RoleDeletionPayload,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'DELETE_COMMUNITY_ROLE_FAILED',
+ +error: true,
+ +payload: Error,
+ +loadingInfo: LoadingInfo,
};
export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 6:47 PM (15 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842727
Default Alt Text
D8639.1765133234.diff (6 KB)
Attached To
Mode
D8639: [keyserver/lib] Introduce the thread actions, endpoints, and responders for deleting a custom role
Attached
Detach File
Event Timeline
Log In to Comment