syntax = "proto3";

package common;

option java_package = "ch.threema.protobuf";

// A unit that may be used in a `oneof` option without any values.
// Note: We're using this to simulate tagged unions.
message Unit {}

// Threema Blob to be uploaded/downloaded from the Blob server.
message Blob {
  // Blob ID as given by the Blob server
  bytes id = 1;

  // Nonce used for encrypting/decrypting the Blob.
  // Note: May be omitted if unambigously defined by the context.
  bytes nonce = 2;

  // Secret (or public) key used for encrypting/decrypting the Blob.
  // Note: May be omitted if unambigously defined by the context.
  bytes key = 3;
}

// Inline Blob data.
message BlobData {
  // Associated Blob ID
  bytes id = 1;

  // The Blob's data
  bytes data = 2;
}

// Generic image.
message Image {
  // Format type of the image
  enum Type {
    JPEG = 0;
  }
  Type type = 1;

  // The image's associated blob.
  Blob blob = 2;
}

// Unique group identity.
message GroupIdentity {
  // Group id as chosen by the group's creator
  fixed64 group_id = 1;

  // Threema ID of the group's creator
  string creator_identity = 2;
}

// Generic image allowing delta updates
message DeltaImage {
  oneof image {
    // The image remains unchanged
    Unit unchanged = 1;
    // The image is empty or was explicitly removed
    Unit removed = 2;
    // The new updated image
    Image updated = 3;
  }
}

// Timespan (year 1970+) with milliseconds accuracy.
//
// Note: This message is invalid if `to` is smaller than `from`.
message Timespan {
  // Start of the timespan (Unix-ish timestamp in milliseconds, inclusive)
  uint64 from = 1;
  // End of the timespan (Unix-ish timestamp in miliseconds, inclusive)
  uint64 to = 2;
}