@@ -46,11 +46,13 @@ export class PostsService {
46
46
async getStatistics ( orgId : string , id : string ) {
47
47
const getPost = await this . getPostsRecursively ( id , true , orgId , true ) ;
48
48
const content = getPost . map ( ( p ) => p . content ) ;
49
- const shortLinksTracking = await this . _shortLinkService . getStatistics ( content ) ;
49
+ const shortLinksTracking = await this . _shortLinkService . getStatistics (
50
+ content
51
+ ) ;
50
52
51
53
return {
52
- clicks : shortLinksTracking
53
- }
54
+ clicks : shortLinksTracking ,
55
+ } ;
54
56
}
55
57
56
58
async getPostsRecursively (
@@ -363,7 +365,10 @@ export class PostsService {
363
365
`Your post has been published on ${ capitalize (
364
366
integration . providerIdentifier
365
367
) } `,
366
- `Your post has been published at ${ publishedPosts [ 0 ] . releaseURL } ` ,
368
+ `Your post has been published on ${ capitalize (
369
+ integration . providerIdentifier
370
+ ) } at ${ publishedPosts [ 0 ] . releaseURL } `,
371
+ true ,
367
372
true
368
373
) ;
369
374
@@ -517,10 +522,10 @@ export class PostsService {
517
522
const post = await this . _postRepository . deletePost ( orgId , group ) ;
518
523
if ( post ?. id ) {
519
524
await this . _workerServiceProducer . delete ( 'post' , post . id ) ;
520
- return { id : post . id } ;
525
+ return { id : post . id } ;
521
526
}
522
527
523
- return { error : true } ;
528
+ return { error : true } ;
524
529
}
525
530
526
531
async countPostsFromDay ( orgId : string , date : Date ) {
@@ -566,8 +571,10 @@ export class PostsService {
566
571
async createPost ( orgId : string , body : CreatePostDto ) {
567
572
const postList = [ ] ;
568
573
for ( const post of body . posts ) {
569
- const messages = post . value . map ( p => p . content ) ;
570
- const updateContent = ! body . shortLink ? messages : await this . _shortLinkService . convertTextToShortLinks ( orgId , messages ) ;
574
+ const messages = post . value . map ( ( p ) => p . content ) ;
575
+ const updateContent = ! body . shortLink
576
+ ? messages
577
+ : await this . _shortLinkService . convertTextToShortLinks ( orgId , messages ) ;
571
578
572
579
post . value = post . value . map ( ( p , i ) => ( {
573
580
...p ,
@@ -624,7 +631,7 @@ export class PostsService {
624
631
postList . push ( {
625
632
postId : posts [ 0 ] . id ,
626
633
integration : post . integration . id ,
627
- } )
634
+ } ) ;
628
635
}
629
636
630
637
return postList ;
@@ -878,4 +885,23 @@ export class PostsService {
878
885
) {
879
886
return this . _postRepository . createComment ( orgId , userId , postId , comment ) ;
880
887
}
888
+
889
+ async sendDigestEmail ( subject : string , orgId : string , since : string ) {
890
+ const getNotificationsForOrgSince =
891
+ await this . _notificationService . getNotificationsSince ( orgId , since ) ;
892
+ if ( getNotificationsForOrgSince . length === 0 ) {
893
+ return ;
894
+ }
895
+
896
+ const message = getNotificationsForOrgSince
897
+ . map ( ( p ) => p . content )
898
+ . join ( '<br />' ) ;
899
+ await this . _notificationService . sendEmailsToOrg (
900
+ orgId ,
901
+ getNotificationsForOrgSince . length === 1
902
+ ? subject
903
+ : '[Postiz] Your latest notifications' ,
904
+ message
905
+ ) ;
906
+ }
881
907
}
0 commit comments