syntax = "proto3";
package qpq.v1;

// Server-push event types (sent on QUIC uni-streams).
// Event type IDs: 1000+.

// Wrapper for a push event.
message PushEvent {
  oneof event {
    NewMessage new_message = 1;
    TypingIndicator typing = 2;
    PresenceUpdate presence = 3;
    GroupMembershipChange membership = 4;
  }
}

message NewMessage {
  bytes channel_id = 1;
  bytes sender_key = 2;
  uint64 seq = 3;
  bytes payload = 4;
  uint64 timestamp_ms = 5;
}

message TypingIndicator {
  bytes channel_id = 1;
  bytes sender_key = 2;
  bool is_typing = 3;
}

message PresenceUpdate {
  bytes identity_key = 1;
  bool online = 2;
  uint64 last_seen_ms = 3;
}

message GroupMembershipChange {
  bytes channel_id = 1;
  bytes actor_key = 2;
  bytes target_key = 3;
  MembershipAction action = 4;
}

enum MembershipAction {
  MEMBERSHIP_ACTION_UNSPECIFIED = 0;
  MEMBERSHIP_ACTION_ADDED = 1;
  MEMBERSHIP_ACTION_REMOVED = 2;
  MEMBERSHIP_ACTION_LEFT = 3;
}
