Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit 2a604e9

Browse files
authored
Conversation (#509)
* Config Local State * Conversation * Update
1 parent 81afc5e commit 2a604e9

File tree

44 files changed

+1939
-1155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1939
-1155
lines changed

packages/server/schema.gql

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,25 @@ type CoursesPayload {
243243
count: Int!
244244
}
245245

246-
type Comment implements BaseModel {
246+
type Conversation implements BaseModel {
247247
id: ID!
248248
orgId: ID!
249249
createdAt: DateTime!
250250
updatedAt: DateTime!
251251
createdByAccountId: String!
252-
targetId: ID!
252+
roomId: String!
253253
content: String!
254+
type: ConversationType!
254255
}
255256

256-
type CommentsPayload {
257-
comments: [Comment!]!
257+
"""Type of an conversation."""
258+
enum ConversationType {
259+
Group
260+
Single
261+
}
262+
263+
type ConversationsPayload {
264+
conversations: [Conversation!]!
258265
count: Int!
259266
}
260267

@@ -279,7 +286,7 @@ type Query {
279286
classworkSubmissions(classworkAssignmentId: ID!): [ClassworkSubmission!]!
280287
findClassworkSubmissionById(classworkSubmissionId: ID!): ClassworkSubmission!
281288
findOneClassworkSubmission(ClassworkAssignment: ID!): ClassworkSubmission!
282-
comments(commentPageOptionInput: CommentPageOptionInput!, lastId: ID, targetId: ID!): CommentsPayload!
289+
conversations(conversationPageOptionInput: ConversationPageOptionInput!, lastId: ID, roomId: String!): ConversationsPayload!
283290
}
284291

285292
input AccountsFilterInput {
@@ -309,7 +316,7 @@ input AvgGradeOfClassworkByCourseOptionInput {
309316
limit: Float = 0
310317
}
311318

312-
input CommentPageOptionInput {
319+
input ConversationPageOptionInput {
313320
limit: Int!
314321
}
315322

@@ -351,7 +358,7 @@ type Mutation {
351358
removeAttachmentsFromClassworkAssignments(attachments: [String!]!, classworkAssignmentId: ID!): ClassworkAssignment!
352359
createClassworkSubmission(createClassworkSubmissionInput: CreateClassworkSubmissionInput!, courseId: ID!): ClassworkSubmission!
353360
setGradeForClassworkSubmission(setGradeForClassworkSubmissionInput: SetGradeForClassworkSubmissionInput!): ClassworkSubmission!
354-
createComment(commentInput: CreateCommentInput!): Comment!
361+
createConversation(conversationInput: CreateConversationInput!): Conversation!
355362
}
356363

357364
input CreateAccountInput {
@@ -454,13 +461,14 @@ input SetGradeForClassworkSubmissionInput {
454461
grade: Float!
455462
}
456463

457-
input CreateCommentInput {
464+
input CreateConversationInput {
458465
createdByAccountId: ID!
459-
targetId: ID!
466+
roomId: ID!
460467
content: String!
468+
type: String
461469
}
462470

463471
type Subscription {
464472
classworkAssignmentCreated(courseId: ID!): ClassworkAssignment!
465-
commentCreated(targetId: String!): Comment!
473+
conversationCreated(roomId: String!): Conversation!
466474
}

packages/server/src/core/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { AcademicModule } from 'modules/academic/academic.module'
99
import { AccountModule } from 'modules/account/account.module'
1010
import { AuthModule } from 'modules/auth/auth.module'
1111
import { ClassworkModule } from 'modules/classwork/classwork.module'
12-
import { CommentModule } from 'modules/comment/comment.module'
12+
import { ConversationModule } from 'modules/conversation/conversation.module'
1313
import { DevtoolModule } from 'modules/devtool/devtool.module'
1414
import { FileStorageModule } from 'modules/fileStorage/fileStorage.module'
1515
import { OrgModule } from 'modules/org/org.module'
@@ -26,7 +26,7 @@ export const appModules = [
2626
FileStorageModule,
2727
OrgOfficeModule,
2828
ClassworkModule,
29-
CommentModule,
29+
ConversationModule,
3030
]
3131

3232
@Module({

packages/server/src/modules/classwork/classwork.resolver.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { Args, ID, ResolveField, Resolver, Root } from '@nestjs/graphql'
22

33
import { CurrentOrg } from 'core'
4-
import { CommentService } from 'modules/comment/comment.service'
4+
import { ConversationService } from 'modules/conversation/conversation.service'
55
import {
6-
CommentPageOptionInput,
7-
CommentsPayload,
8-
} from 'modules/comment/comment.type'
6+
ConversationPageOptionInput,
7+
ConversationsPayload,
8+
} from 'modules/conversation/conversation.type'
99
import { Org } from 'modules/org/models/Org'
1010
import { ANY } from 'types'
1111

1212
import { Classwork, ClassworkType } from './models/Classwork'
1313

1414
@Resolver((_of) => Classwork)
1515
export class ClassworkResolver {
16-
constructor(private readonly commentService: CommentService) {}
16+
constructor(private readonly conversationService: ConversationService) {}
1717

1818
/**
1919
*START CLASSWORK RESOLVER
@@ -33,19 +33,22 @@ export class ClassworkResolver {
3333
return ['ClassworkMaterial', 'ClassworkAssignment']
3434
}
3535

36-
@ResolveField((_returns) => CommentsPayload)
36+
@ResolveField((_returns) => ConversationsPayload)
3737
comments(
3838
@Root() { id },
3939
@CurrentOrg() org: Org,
4040
@Args('lastId', { type: () => ID, nullable: true }) lastId: string,
41-
@Args('commentPageOptionInput')
42-
commentPageOptionInput: CommentPageOptionInput,
43-
): Promise<CommentsPayload> {
44-
return this.commentService.listCommentByTargetId(commentPageOptionInput, {
45-
orgId: org.id,
46-
lastId,
47-
targetId: id,
48-
})
41+
@Args('conversationPageOptionInput')
42+
conversationPageOptionInput: ConversationPageOptionInput,
43+
): Promise<ConversationsPayload> {
44+
return this.conversationService.listConversationByTargetId(
45+
conversationPageOptionInput,
46+
{
47+
orgId: org.id,
48+
lastId,
49+
roomId: id,
50+
},
51+
)
4952
}
5053

5154
/**

packages/server/src/modules/comment/comment.resolver.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

packages/server/src/modules/comment/comment.service.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

packages/server/src/modules/comment/comment.type.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/server/src/modules/comment/model/Comment.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/server/src/modules/comment/comment.module.ts renamed to packages/server/src/modules/conversation/conversation.module.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { AuthModule } from 'modules/auth/auth.module'
77
import { FileStorageModule } from 'modules/fileStorage/fileStorage.module'
88
import { OrgModule } from 'modules/org/org.module'
99

10-
import { CommentResolver } from './comment.resolver'
11-
import { CommentService } from './comment.service'
12-
import { Comment } from './model/Comment'
10+
import { ConversationResolver } from './conversation.resolver'
11+
import { ConversationService } from './conversation.service'
12+
import { Conversation } from './model/Conversation'
1313

1414
@Global()
1515
@Module({
@@ -18,9 +18,9 @@ import { Comment } from './model/Comment'
1818
AccountModule,
1919
FileStorageModule,
2020
OrgModule,
21-
TypegooseModule.forFeature([Comment, Course]),
21+
TypegooseModule.forFeature([Conversation, Course]),
2222
],
23-
providers: [CommentService, CommentResolver],
24-
exports: [CommentService],
23+
providers: [ConversationService, ConversationResolver],
24+
exports: [ConversationService],
2525
})
26-
export class CommentModule {}
26+
export class ConversationModule {}

0 commit comments

Comments
 (0)