How to use the @wireapp/protocol-messaging.Availability.Type function in @wireapp/protocol-messaging

To help you get started, we’ve selected a few @wireapp/protocol-messaging examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireapp / wire-webapp / test / unit_tests / cryptography / CryptographyMapperSpec.js View on Github external
return mapper.mapGenericMessage(generic_message, event).then(event_json => {
        expect(isObject(event_json)).toBeTruthy();
        expect(event_json.type).toBe(ClientEvent.USER.AVAILABILITY);
        expect(event_json.conversation).toBe(event.conversation);
        expect(event_json.from).toBe(event.from);
        expect(event_json.time).toBe(event.time);
        expect(event_json.id).toBe(generic_message.messageId);
        expect(event_json.data.availability).toBe(Availability.Type.AVAILABLE);
      });
    });
github wireapp / wire-webapp / src / script / notification / NotificationRepository.ts View on Github external
notify(
    messageEntity: ContentMessage,
    connectionEntity: ConnectionEntity,
    conversationEntity: Conversation,
  ): Promise {
    const isUserAway = this.selfUser().availability() === Availability.Type.AWAY;

    if (isUserAway) {
      return Promise.resolve();
    }

    const isUserBusy = this.selfUser().availability() === Availability.Type.BUSY;
    const isSelfMentionOrReply = messageEntity.is_content() && messageEntity.isUserTargeted(this.selfUser().id);
    const isCallMessage = messageEntity.super_type === SuperType.CALL;

    if (isUserBusy && !isSelfMentionOrReply && !isCallMessage) {
      return Promise.resolve();
    }

    const notifyInConversation = conversationEntity
      ? NotificationRepository.shouldNotifyInConversation(conversationEntity, messageEntity, this.selfUser().id)
      : true;
github wireapp / wire-webapp / src / script / cryptography / CryptographyMapper.js View on Github external
_mapAvailability(availability) {
    const knownAvailabilityTypes = [
      Availability.Type.NONE,
      Availability.Type.AVAILABLE,
      Availability.Type.AWAY,
      Availability.Type.BUSY,
    ];

    if (!knownAvailabilityTypes.includes(availability.type)) {
      const message = `Availability type "${availability.type}" is unknown.`;
      throw new z.error.CryptographyError(z.error.CryptographyError.TYPE.UNHANDLED_TYPE, message);
    }

    return {
      data: {
        availability: availability.type,
      },
      type: ClientEvent.USER.AVAILABILITY,
    };
  }
github wireapp / wire-webapp / src / script / cryptography / CryptographyMapper.js View on Github external
_mapAvailability(availability) {
    const knownAvailabilityTypes = [
      Availability.Type.NONE,
      Availability.Type.AVAILABLE,
      Availability.Type.AWAY,
      Availability.Type.BUSY,
    ];

    if (!knownAvailabilityTypes.includes(availability.type)) {
      const message = `Availability type "${availability.type}" is unknown.`;
      throw new z.error.CryptographyError(z.error.CryptographyError.TYPE.UNHANDLED_TYPE, message);
    }

    return {
      data: {
        availability: availability.type,
      },
      type: ClientEvent.USER.AVAILABILITY,
    };
github wireapp / wire-webapp / src / script / cryptography / CryptographyMapper.js View on Github external
_mapAvailability(availability) {
    const knownAvailabilityTypes = [
      Availability.Type.NONE,
      Availability.Type.AVAILABLE,
      Availability.Type.AWAY,
      Availability.Type.BUSY,
    ];

    if (!knownAvailabilityTypes.includes(availability.type)) {
      const message = `Availability type "${availability.type}" is unknown.`;
      throw new z.error.CryptographyError(z.error.CryptographyError.TYPE.UNHANDLED_TYPE, message);
    }

    return {
      data: {
        availability: availability.type,
      },
      type: ClientEvent.USER.AVAILABILITY,
    };
  }
github wireapp / wire-webapp / src / script / view_model / content / PreferencesAccountViewModel.js View on Github external
this.availabilityLabel = ko.pureComputed(() => {
      let label = nameFromType(this.availability());

      const noStatusSet = this.availability() === Availability.Type.NONE;
      if (noStatusSet) {
        label = t('preferencesAccountAvaibilityUnset');
      }

      return label;
    });
github wireapp / wire-webapp / src / script / entity / User.js View on Github external
return false;
      }
      return this.devices().every(client_et => client_et.meta.isVerified());
    });
    this.isOnLegalHold = ko.pureComputed(() => {
      return this.devices().some(client_et => client_et.isLegalHold());
    });

    const _hasPendingLegalHold = ko.observable(false);
    this.hasPendingLegalHold = ko.pureComputed({
      owner: this,
      read: () => this.is_me && !this.isOnLegalHold() && _hasPendingLegalHold(),
      write: value => _hasPendingLegalHold(value),
    });

    this.availability = ko.observable(Availability.Type.NONE);

    this.expirationRemaining = ko.observable(0);
    this.expirationText = ko.observable('');
    this.expirationIsUrgent = ko.observable(false);
    this.expirationRemainingText = ko.observable('');
    this.expirationIntervalId = undefined;
    this.expirationTimeoutId = undefined;
    this.isExpired = ko.observable(false);
  }
github wireapp / wire-webapp / src / script / user / AvailabilityMapper.ts View on Github external
export const nameFromType = (availabilityType: Availability.Type) => {
  const TYPE_STRINGS = {
    [Availability.Type.AVAILABLE]: t('userAvailabilityAvailable'),
    [Availability.Type.AWAY]: t('userAvailabilityAway'),
    [Availability.Type.BUSY]: t('userAvailabilityBusy'),
    [Availability.Type.NONE]: t('userAvailabilityNone'),
  };

  const string = TYPE_STRINGS[availabilityType];
  if (string) {
    return string;
  }
  throw new z.error.UserError(BaseError.TYPE.INVALID_PARAMETER);
};
github wireapp / wire-webapp / src / script / notification / NotificationRepository.ts View on Github external
notify(
    messageEntity: ContentMessage,
    connectionEntity: ConnectionEntity,
    conversationEntity: Conversation,
  ): Promise {
    const isUserAway = this.selfUser().availability() === Availability.Type.AWAY;

    if (isUserAway) {
      return Promise.resolve();
    }

    const isUserBusy = this.selfUser().availability() === Availability.Type.BUSY;
    const isSelfMentionOrReply = messageEntity.is_content() && messageEntity.isUserTargeted(this.selfUser().id);
    const isCallMessage = messageEntity.super_type === SuperType.CALL;

    if (isUserBusy && !isSelfMentionOrReply && !isCallMessage) {
      return Promise.resolve();
    }

    const notifyInConversation = conversationEntity
      ? NotificationRepository.shouldNotifyInConversation(conversationEntity, messageEntity, this.selfUser().id)
      : true;

    if (notifyInConversation) {
      this.notifySound(messageEntity);
      return this.notifyBanner(messageEntity, connectionEntity, conversationEntity);
    }
github wireapp / wire-webapp / src / script / cryptography / CryptographyMapper.js View on Github external
_mapAvailability(availability) {
    const knownAvailabilityTypes = [
      Availability.Type.NONE,
      Availability.Type.AVAILABLE,
      Availability.Type.AWAY,
      Availability.Type.BUSY,
    ];

    if (!knownAvailabilityTypes.includes(availability.type)) {
      const message = `Availability type "${availability.type}" is unknown.`;
      throw new z.error.CryptographyError(z.error.CryptographyError.TYPE.UNHANDLED_TYPE, message);
    }

    return {
      data: {
        availability: availability.type,
      },
      type: ClientEvent.USER.AVAILABILITY,
    };
  }