reply only allowed text

This commit is contained in:
Hongbo Wu 2024-04-09 11:16:20 +08:00
parent e7fc1316dd
commit f2f18eb12b
4 changed files with 39 additions and 9 deletions

View file

@ -58,6 +58,13 @@ export type AddPopularReadSuccess = {
pageId: Scalars['String'];
};
export enum AllowedReply {
Confirm = 'CONFIRM',
Okay = 'OKAY',
Subscribe = 'SUBSCRIBE',
Yes = 'YES'
}
export type ApiKey = {
__typename?: 'ApiKey';
createdAt: Scalars['Date'];
@ -1839,7 +1846,7 @@ export type MutationRecommendHighlightsArgs = {
export type MutationReplyToEmailArgs = {
recentEmailId: Scalars['ID'];
reply: Scalars['String'];
reply: AllowedReply;
};
@ -2282,6 +2289,8 @@ export type RecentEmail = {
from: Scalars['String'];
html?: Maybe<Scalars['String']>;
id: Scalars['ID'];
reply?: Maybe<Scalars['String']>;
replyTo?: Maybe<Scalars['String']>;
subject: Scalars['String'];
text: Scalars['String'];
to: Scalars['String'];
@ -3931,6 +3940,7 @@ export type ResolversTypes = {
AddPopularReadErrorCode: AddPopularReadErrorCode;
AddPopularReadResult: ResolversTypes['AddPopularReadError'] | ResolversTypes['AddPopularReadSuccess'];
AddPopularReadSuccess: ResolverTypeWrapper<AddPopularReadSuccess>;
AllowedReply: AllowedReply;
ApiKey: ResolverTypeWrapper<ApiKey>;
ApiKeysError: ResolverTypeWrapper<ApiKeysError>;
ApiKeysErrorCode: ApiKeysErrorCode;
@ -6324,6 +6334,8 @@ export type RecentEmailResolvers<ContextType = ResolverContext, ParentType exten
from?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
html?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
reply?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
replyTo?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
subject?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
text?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
to?: Resolver<ResolversTypes['String'], ParentType, ContextType>;

View file

@ -37,6 +37,13 @@ type AddPopularReadSuccess {
pageId: String!
}
enum AllowedReply {
CONFIRM
OKAY
SUBSCRIBE
YES
}
type ApiKey {
createdAt: Date!
expiresAt: Date!
@ -1454,7 +1461,7 @@ type Mutation {
optInFeature(input: OptInFeatureInput!): OptInFeatureResult!
recommend(input: RecommendInput!): RecommendResult!
recommendHighlights(input: RecommendHighlightsInput!): RecommendHighlightsResult!
replyToEmail(recentEmailId: ID!, reply: String!): ReplyToEmailResult!
replyToEmail(recentEmailId: ID!, reply: AllowedReply!): ReplyToEmailResult!
reportItem(input: ReportItemInput!): ReportItemResult!
revokeApiKey(id: ID!): RevokeApiKeyResult!
saveArticleReadingProgress(input: SaveArticleReadingProgressInput!): SaveArticleReadingProgressResult!
@ -1672,6 +1679,8 @@ type RecentEmail {
from: String!
html: String
id: ID!
reply: String
replyTo: String
subject: String!
text: String!
to: String!

View file

@ -127,7 +127,7 @@ export const replyToEmailResolver = authorized<
ReplyToEmailSuccess,
ReplyToEmailError,
MutationReplyToEmailArgs
>(async (_, { recentEmailId }, { uid, log }) => {
>(async (_, { recentEmailId, reply }, { uid, log }) => {
const repo = getRepository(ReceivedEmail)
const recentEmail = await repo.findOneBy({
id: recentEmailId,
@ -142,8 +142,6 @@ export const replyToEmailResolver = authorized<
}
}
const reply = 'Okay'
const result = await enqueueSendEmail({
to: recentEmail.replyTo || recentEmail.from, // send to the reply-to address if it exists or the from address
subject: 'Re: ' + recentEmail.subject,
@ -151,10 +149,14 @@ export const replyToEmailResolver = authorized<
from: recentEmail.to,
})
// update received email reply
await repo.update(recentEmailId, { reply })
const success = !!result
if (success) {
// update received email reply
await repo.update(recentEmailId, { reply })
}
return {
success: !!result,
success,
}
})

View file

@ -3082,6 +3082,13 @@ const schema = gql`
UNAUTHORIZED
}
enum AllowedReply {
YES
OKAY
CONFIRM
SUBSCRIBE
}
# Mutations
type Mutation {
googleLogin(input: GoogleLoginInput!): LoginResult!
@ -3181,7 +3188,7 @@ const schema = gql`
contentType: String!
): UploadImportFileResult!
markEmailAsItem(recentEmailId: ID!): MarkEmailAsItemResult!
replyToEmail(recentEmailId: ID!, reply: String!): ReplyToEmailResult!
replyToEmail(recentEmailId: ID!, reply: AllowedReply!): ReplyToEmailResult!
bulkAction(
query: String!
action: BulkActionType!