@@ -49,8 +49,10 @@ export default {
4949 let lastUpdatedTimestamp = 0 ;
5050 for await ( const page of pagesStream ) {
5151 propertyValues [ page . id ] = { } ;
52- for ( const property of properties ) {
53- propertyValues [ page . id ] [ property ] = md5 ( JSON . stringify ( page . properties [ property ] ) ) ;
52+ for ( const propertyName of properties ) {
53+ const pageProperty = page . properties [ propertyName ] ;
54+ this . maybeRemoveFileSubItems ( pageProperty ) ;
55+ propertyValues [ page . id ] [ propertyName ] = md5 ( JSON . stringify ( pageProperty ) ) ;
5456 }
5557 lastUpdatedTimestamp = Math . max (
5658 lastUpdatedTimestamp ,
@@ -80,6 +82,17 @@ export default {
8082 const { properties } = await this . notion . retrieveDatabase ( this . databaseId ) ;
8183 return Object . keys ( properties ) ;
8284 } ,
85+ maybeRemoveFileSubItems ( property ) {
86+ // Files & Media type:
87+ // `url` and `expiry_time` are constantly updated by Notion, so ignore these fields
88+ if ( property . type === "files" ) {
89+ for ( const file of property . files ) {
90+ if ( file . type === "file" ) {
91+ delete file . file ;
92+ }
93+ }
94+ }
95+ } ,
8396 generateMeta ( obj , summary ) {
8497 const { id } = obj ;
8598 const title = this . notion . extractPageTitle ( obj ) ;
@@ -119,13 +132,15 @@ export default {
119132 ) ;
120133
121134 let propertyChangeFound = false ;
122- for ( const property of properties ) {
123- const currentProperty = md5 ( JSON . stringify ( page . properties [ property ] ) ) ;
124- if ( ! propertyValues [ page . id ] || currentProperty !== propertyValues [ page . id ] [ property ] ) {
135+ for ( const propertyName of properties ) {
136+ const pageProperty = JSON . parse ( JSON . stringify ( page . properties [ propertyName ] ) ) ;
137+ this . maybeRemoveFileSubItems ( pageProperty ) ;
138+ const currentProperty = md5 ( JSON . stringify ( pageProperty ) ) ;
139+ if ( ! propertyValues [ page . id ] || currentProperty !== propertyValues [ page . id ] [ propertyName ] ) {
125140 propertyChangeFound = true ;
126141 propertyValues [ page . id ] = {
127142 ...propertyValues [ page . id ] ,
128- [ property ] : currentProperty ,
143+ [ propertyName ] : currentProperty ,
129144 } ;
130145 }
131146 }
0 commit comments