@ -79,7 +79,8 @@ import {schema, SCHEMA_VERSION} from 'app/common/schema';
import { MetaRowRecord , SingleCell } from 'app/common/TableData' ;
import { MetaRowRecord , SingleCell } from 'app/common/TableData' ;
import { TelemetryEvent , TelemetryMetadataByLevel } from 'app/common/Telemetry' ;
import { TelemetryEvent , TelemetryMetadataByLevel } from 'app/common/Telemetry' ;
import { FetchUrlOptions , UploadResult } from 'app/common/uploads' ;
import { FetchUrlOptions , UploadResult } from 'app/common/uploads' ;
import { Document as APIDocument , DocReplacementOptions , DocState , DocStateComparison } from 'app/common/UserAPI' ;
import { Document as APIDocument , DocReplacementOptions ,
DocState , DocStateComparison , NEW_DOCUMENT_CODE } from 'app/common/UserAPI' ;
import { convertFromColumn } from 'app/common/ValueConverter' ;
import { convertFromColumn } from 'app/common/ValueConverter' ;
import { guessColInfo } from 'app/common/ValueGuesser' ;
import { guessColInfo } from 'app/common/ValueGuesser' ;
import { parseUserAction } from 'app/common/ValueParser' ;
import { parseUserAction } from 'app/common/ValueParser' ;
@ -1574,17 +1575,22 @@ export class ActiveDoc extends EventEmitter {
} ;
} ;
const isShared = new Set < string > ( ) ;
const isShared = new Set < string > ( ) ;
// Collect users the document is shared with.
const userId = getDocSessionUserId ( docSession ) ;
const userId = getDocSessionUserId ( docSession ) ;
if ( ! userId ) { throw new Error ( 'Cannot determine user' ) ; }
if ( ! userId ) { throw new Error ( 'Cannot determine user' ) ; }
const db = this . getHomeDbManager ( ) ;
if ( db ) {
const parsed = parseUrlId ( this . docName ) ;
const access = db . unwrapQueryResult (
// If this is not a temporary document (i.e. created by anonymous user).
await db . getDocAccess ( { userId , urlId : this.docName } , {
if ( parsed . trunkId !== NEW_DOCUMENT_CODE ) {
flatten : true , excludeUsersWithoutAccess : true ,
// Collect users the document is shared with.
} ) ) ;
const db = this . getHomeDbManager ( ) ;
result . users = access . users ;
if ( db ) {
result . users . forEach ( user = > isShared . add ( normalizeEmail ( user . email ) ) ) ;
const access = db . unwrapQueryResult (
await db . getDocAccess ( { userId , urlId : this.docName } , {
flatten : true , excludeUsersWithoutAccess : true ,
} ) ) ;
result . users = access . users ;
result . users . forEach ( user = > isShared . add ( normalizeEmail ( user . email ) ) ) ;
}
}
}
// Collect users from user attribute tables. Omit duplicates with users the document is
// Collect users from user attribute tables. Omit duplicates with users the document is