Skip to content

Commit

Permalink
- added post and comment report module
Browse files Browse the repository at this point in the history
  • Loading branch information
Sorbh committed Mar 3, 2022
1 parent 523ba61 commit 9835a5f
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .dart_tool/package_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@
"languageVersion": "2.15"
}
],
"generated": "2022-02-28T14:52:16.619036Z",
"generated": "2022-03-02T14:43:54.851642Z",
"generator": "pub",
"generatorVersion": "2.16.0"
}
14 changes: 14 additions & 0 deletions lib/core/service_locator/sdk_service_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import 'package:amity_sdk/domain/composer_usecase/user_compose_usecase.dart';
import 'package:amity_sdk/domain/domain.dart';
import 'package:amity_sdk/domain/repo/reaction_repo.dart';
import 'package:amity_sdk/domain/usecase/comment/comment_create_usecase.dart';
import 'package:amity_sdk/domain/usecase/comment/comment_flag_usecase.dart';
import 'package:amity_sdk/domain/usecase/comment/comment_query_usecase.dart';
import 'package:amity_sdk/domain/usecase/comment/comment_unflag_usecase.dart';
import 'package:amity_sdk/domain/usecase/post/post_flag_usecase.dart';
import 'package:amity_sdk/domain/usecase/post/post_unflag_usecase.dart';
import 'package:amity_sdk/domain/usecase/reaction/add_reaction_usecase.dart';
import 'package:amity_sdk/domain/usecase/reaction/remove_reaction_usecase.dart';
import 'package:amity_sdk/public/public.dart';
Expand Down Expand Up @@ -187,6 +191,16 @@ class SdkServiceLocator {
serviceLocator.registerLazySingleton<CommentQueryUsecase>(
() => CommentQueryUsecase(commentRepo: serviceLocator()));

serviceLocator.registerLazySingleton<PostFlagUsecase>(
() => PostFlagUsecase(postRepo: serviceLocator()));
serviceLocator.registerLazySingleton<PostUnflagUsecase>(
() => PostUnflagUsecase(postRepo: serviceLocator()));

serviceLocator.registerLazySingleton<CommentFlagUsecase>(
() => CommentFlagUsecase(commentRepo: serviceLocator()));
serviceLocator.registerLazySingleton<CommentUnflagUsecase>(
() => CommentUnflagUsecase(commentRepo: serviceLocator()));

///----------------------------------- Public Layer -----------------------------------///
//-public_repo
serviceLocator.registerLazySingleton(() => PostRepository());
Expand Down
2 changes: 1 addition & 1 deletion lib/domain/model/amity_post.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/core/enum/reaction_reference_type.dart';
import 'package:amity_sdk/domain/domain.dart';
import 'package:amity_sdk/public/query_builder/reaction/add_reaction_query_builder.dart';
import 'package:amity_sdk/public/query_builder/reaction/reaction_query_builder.dart';

class AmityPost {
String? postId;
Expand Down
19 changes: 19 additions & 0 deletions lib/domain/usecase/comment/comment_flag_usecase.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/domain/domain.dart';

class CommentFlagUsecase extends UseCase<bool, String> {
final CommentRepo commentRepo;

CommentFlagUsecase({required this.commentRepo});

@override
Future<bool> get(String params) {
return commentRepo.flagComment(params);
}

@override
Stream<bool> listen(String params) {
// TODO: implement listen
throw UnimplementedError();
}
}
19 changes: 19 additions & 0 deletions lib/domain/usecase/comment/comment_unflag_usecase.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/domain/domain.dart';

class CommentUnflagUsecase extends UseCase<bool, String> {
final CommentRepo commentRepo;

CommentUnflagUsecase({required this.commentRepo});

@override
Future<bool> get(String params) {
return commentRepo.unflagComment(params);
}

@override
Stream<bool> listen(String params) {
// TODO: implement listen
throw UnimplementedError();
}
}
19 changes: 19 additions & 0 deletions lib/domain/usecase/post/post_flag_usecase.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/domain/domain.dart';

class PostFlagUsecase extends UseCase<bool, String> {
final PostRepo postRepo;

PostFlagUsecase({required this.postRepo});

@override
Future<bool> get(String params) {
return postRepo.flagPost(params);
}

@override
Stream<bool> listen(String params) {
// TODO: implement listen
throw UnimplementedError();
}
}
19 changes: 19 additions & 0 deletions lib/domain/usecase/post/post_unflag_usecase.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/domain/domain.dart';

class PostUnflagUsecase extends UseCase<bool, String> {
final PostRepo postRepo;

PostUnflagUsecase({required this.postRepo});

@override
Future<bool> get(String params) {
return postRepo.unflagPost(params);
}

@override
Stream<bool> listen(String params) {
// TODO: implement listen
throw UnimplementedError();
}
}
22 changes: 22 additions & 0 deletions lib/public/model_extenstion/amity_comment_extenstion.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/core/enum/reaction_reference_type.dart';
import 'package:amity_sdk/domain/domain.dart';
import 'package:amity_sdk/public/query_builder/comment/comment_flag_query_builder.dart';
import 'package:amity_sdk/public/query_builder/reaction/reaction_query_builder.dart';

extension AmityCommentExtension on AmityComment {
AddReactionQueryBuilder react() {
return AddReactionQueryBuilder(
addReactionUsecase: serviceLocator(),
removeReactionUsecase: serviceLocator(),
referenceType: ReactionReferenceType.COMMENT.value,
referenceId: commentId!);
}

CommentFlagQueryBuilder report() {
return CommentFlagQueryBuilder(
commentFlagUsecase: serviceLocator(),
commentUnflagUsecase: serviceLocator(),
commentId: commentId!);
}
}
10 changes: 9 additions & 1 deletion lib/public/model_extenstion/amity_post_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import 'package:amity_sdk/core/core.dart';
import 'package:amity_sdk/core/enum/reaction_reference_type.dart';
import 'package:amity_sdk/domain/domain.dart';
import 'package:amity_sdk/public/query_builder/comment/comment_create_query_builder.dart';
import 'package:amity_sdk/public/query_builder/reaction/add_reaction_query_builder.dart';
import 'package:amity_sdk/public/query_builder/post/post_flag_query_builder.dart';
import 'package:amity_sdk/public/query_builder/reaction/reaction_query_builder.dart';

extension AmityPostExtension on AmityPost {
AddReactionQueryBuilder react() {
Expand All @@ -18,4 +19,11 @@ extension AmityPostExtension on AmityPost {
useCase: serviceLocator(),
).post(postId!);
}

PostFlagQueryBuilder report() {
return PostFlagQueryBuilder(
postFlagUsecase: serviceLocator(),
postUnflagUsecase: serviceLocator(),
postId: postId!);
}
}
22 changes: 22 additions & 0 deletions lib/public/query_builder/comment/comment_flag_query_builder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:amity_sdk/domain/usecase/Comment/Comment_flag_usecase.dart';
import 'package:amity_sdk/domain/usecase/comment/comment_unflag_usecase.dart';

class CommentFlagQueryBuilder {
final CommentFlagUsecase _commentFlagUsecase;
final CommentUnflagUsecase _commentUnflagUsecase;
final String _commentId;
CommentFlagQueryBuilder(
{required CommentFlagUsecase commentFlagUsecase,
required CommentUnflagUsecase commentUnflagUsecase,
required String commentId})
: _commentFlagUsecase = commentFlagUsecase,
_commentUnflagUsecase = commentUnflagUsecase,
_commentId = commentId;
Future<bool> flag() {
return _commentFlagUsecase.get(_commentId);
}

Future<bool> unflag() {
return _commentUnflagUsecase.get(_commentId);
}
}
22 changes: 22 additions & 0 deletions lib/public/query_builder/post/post_flag_query_builder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:amity_sdk/domain/usecase/post/post_flag_usecase.dart';
import 'package:amity_sdk/domain/usecase/post/post_unflag_usecase.dart';

class PostFlagQueryBuilder {
final PostFlagUsecase _postFlagUsecase;
final PostUnflagUsecase _postUnflagUsecase;
final String _postId;
PostFlagQueryBuilder(
{required PostFlagUsecase postFlagUsecase,
required PostUnflagUsecase postUnflagUsecase,
required String postId})
: _postFlagUsecase = postFlagUsecase,
_postUnflagUsecase = postUnflagUsecase,
_postId = postId;
Future<bool> flag() {
return _postFlagUsecase.get(_postId);
}

Future<bool> unflag() {
return _postUnflagUsecase.get(_postId);
}
}

This file was deleted.

0 comments on commit 9835a5f

Please sign in to comment.