You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
import { SignalService } from '../../../../protobuf';
 | 
						|
import { LokiProfile } from '../../../../types/Message';
 | 
						|
import { ContentMessage } from '../ContentMessage';
 | 
						|
import { MessageParams } from '../Message';
 | 
						|
import { buildProfileForOutgoingMessage } from '../visibleMessage/VisibleMessage';
 | 
						|
 | 
						|
// tslint:disable-next-line: no-empty-interface
 | 
						|
export interface MessageRequestResponseParams extends MessageParams {
 | 
						|
  lokiProfile?: LokiProfile;
 | 
						|
}
 | 
						|
 | 
						|
export class MessageRequestResponse extends ContentMessage {
 | 
						|
  // we actually send a response only if it is an accept
 | 
						|
  // private readonly isApproved: boolean;
 | 
						|
  private readonly profileKey?: Uint8Array;
 | 
						|
  private readonly profile?: SignalService.DataMessage.ILokiProfile;
 | 
						|
 | 
						|
  constructor(params: MessageRequestResponseParams) {
 | 
						|
    super({
 | 
						|
      timestamp: params.timestamp,
 | 
						|
    } as MessageRequestResponseParams);
 | 
						|
 | 
						|
    const profile = buildProfileForOutgoingMessage(params);
 | 
						|
    this.profile = profile.lokiProfile;
 | 
						|
    this.profileKey = profile.profileKey;
 | 
						|
  }
 | 
						|
 | 
						|
  public contentProto(): SignalService.Content {
 | 
						|
    return new SignalService.Content({
 | 
						|
      messageRequestResponse: this.messageRequestResponseProto(),
 | 
						|
    });
 | 
						|
  }
 | 
						|
 | 
						|
  public messageRequestResponseProto(): SignalService.MessageRequestResponse {
 | 
						|
    return new SignalService.MessageRequestResponse({
 | 
						|
      isApproved: true,
 | 
						|
      profileKey: this.profileKey?.length ? this.profileKey : undefined,
 | 
						|
      profile: this.profile,
 | 
						|
    });
 | 
						|
  }
 | 
						|
}
 |