@@ -20,77 +20,66 @@ interface SafeUser {
20
20
me : boolean ;
21
21
}
22
22
23
- export class SafeCommentsCollection_ {
24
- private readonly unsafeComments : GoogleAppsScript . Drive_v3 . Drive . V3 . Collection . CommentsCollection ;
25
-
26
- public constructor ( ) {
27
- // TODO: Remove and access directly
28
- this . unsafeComments = Drive . Comments ;
29
- }
30
-
31
- private static commentIsSafe (
32
- comment : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . Comment ,
33
- ) : comment is SafeComment {
34
- return (
35
- comment . author !== undefined &&
36
- SafeCommentsCollection_ . userIsSafe ( comment . author ) &&
37
- comment . id !== undefined &&
38
- comment . content !== undefined &&
39
- comment . replies ?. every ( ( reply ) =>
40
- SafeCommentsCollection_ . commentReplyIsSafe ( reply ) ,
41
- ) === true
42
- ) ;
43
- }
23
+ function commentIsSafe_ (
24
+ comment : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . Comment ,
25
+ ) : comment is SafeComment {
26
+ return (
27
+ comment . author !== undefined &&
28
+ userIsSafe_ ( comment . author ) &&
29
+ comment . id !== undefined &&
30
+ comment . content !== undefined &&
31
+ comment . replies ?. every ( ( reply ) => commentReplyIsSafe_ ( reply ) ) === true
32
+ ) ;
33
+ }
44
34
45
- private static commentListIsSafe (
46
- commentList : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . CommentList ,
47
- ) : commentList is SafeCommentList {
48
- return (
49
- commentList . comments ?. every ( ( comment ) =>
50
- SafeCommentsCollection_ . commentIsSafe ( comment ) ,
51
- ) === true
52
- ) ;
53
- }
35
+ function commentListIsSafe_ (
36
+ commentList : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . CommentList ,
37
+ ) : commentList is SafeCommentList {
38
+ return (
39
+ commentList . comments ?. every ( ( comment ) => commentIsSafe_ ( comment ) ) === true
40
+ ) ;
41
+ }
54
42
55
- private static commentReplyIsSafe (
56
- commentReply : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . Reply ,
57
- ) : commentReply is SafeReply {
58
- return (
59
- commentReply . author !== undefined &&
60
- SafeCommentsCollection_ . userIsSafe ( commentReply . author ) &&
61
- commentReply . content !== undefined
62
- ) ;
63
- }
43
+ function commentReplyIsSafe_ (
44
+ commentReply : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . Reply ,
45
+ ) : commentReply is SafeReply {
46
+ return (
47
+ commentReply . author !== undefined &&
48
+ userIsSafe_ ( commentReply . author ) &&
49
+ commentReply . content !== undefined
50
+ ) ;
51
+ }
64
52
65
- private static userIsSafe (
66
- user : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . User ,
67
- ) : user is SafeUser {
68
- return user . me !== undefined && user . displayName !== undefined ;
69
- }
53
+ function userIsSafe_ (
54
+ user : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . User ,
55
+ ) : user is SafeUser {
56
+ return user . me !== undefined && user . displayName !== undefined ;
57
+ }
70
58
71
- public create (
59
+ export const SafeCommentsCollection_ = {
60
+ create : (
72
61
resource : GoogleAppsScript . Drive_v3 . Drive . V3 . Schema . Comment ,
73
62
fileId : string ,
74
- ) : SafeComment {
75
- const ret = this . unsafeComments . create ( resource , fileId ) ;
76
- if ( ! SafeCommentsCollection_ . commentIsSafe ( ret ) ) {
63
+ ) : SafeComment => {
64
+ const ret = Drive . Comments . create ( resource , fileId ) ;
65
+ if ( ! commentIsSafe_ ( ret ) ) {
77
66
throw new Error ( "" ) ;
78
67
}
79
68
return ret ;
80
- }
69
+ } ,
81
70
82
- public list (
71
+ list : (
83
72
fileId : string ,
84
73
optionalArgs : {
85
74
fields ?: string ;
86
75
maxResults ?: number ;
87
76
pageToken ?: string | undefined ;
88
77
} = { } ,
89
- ) : SafeCommentList {
90
- const ret = this . unsafeComments . list ( fileId , optionalArgs ) ;
91
- if ( ! SafeCommentsCollection_ . commentListIsSafe ( ret ) ) {
78
+ ) : SafeCommentList => {
79
+ const ret = Drive . Comments . list ( fileId , optionalArgs ) ;
80
+ if ( ! commentListIsSafe_ ( ret ) ) {
92
81
throw new Error ( "" ) ;
93
82
}
94
83
return ret ;
95
- }
96
- }
84
+ } ,
85
+ } ;
0 commit comments