syntax = "proto3";
option java_package = "io.textile.pb";
option go_package = "go-textile/pb";

import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";
import "model.proto";

// THREADS //

message AddThreadConfig {
    string key                 = 1;
    string name                = 2;
    Schema schema              = 3;
    Thread.Type type           = 4;
    Thread.Sharing sharing     = 5;
    repeated string whitelist  = 6;
    bool force                 = 7; // force key by auto-incrementing

    message Schema {
        string id     = 1;
        string json   = 2;
        Preset preset = 3;

        enum Preset {
            NONE        = 0;
            BLOB        = 1;
            CAMERA_ROLL = 2;
            MEDIA       = 3;
        }
    }
}

message BlockViz {
    string dots = 1;
    int32 count = 2;
    string next = 3;
}

// FILES //

message Step {
    string name = 1;
    Link link   = 2;
}

message Directory {
    map<string, FileIndex> files = 1;
}

message DirectoryList {
    repeated Directory items = 1;
}

message Keys {
    map<string, string> files = 1;
}

// INVITES

message InviteView {
    string id                      = 1;
    string name                    = 2;
    User inviter                   = 3;
    google.protobuf.Timestamp date = 4;
}

message InviteViewList {
    repeated InviteView items = 1;
}

message ExternalInvite {
    string id      = 1;
    string key     = 2;
    string inviter = 3;
}

// FEED //

message FeedRequest {
    string thread = 1;
    string offset = 2;
    int32 limit   = 3;
    Mode mode     = 4;

    enum Mode {
        CHRONO    = 0;
        ANNOTATED = 1;
        STACKS    = 2;
    }
}

message FeedItem {
    string block                = 1;
    string thread               = 2;
    google.protobuf.Any payload = 3;
}

message FeedItemList {
    repeated FeedItem items = 1;
    int32 count             = 2;
    string next             = 3;
}

message Merge {
	option deprecated = true;
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    repeated FeedItem targets      = 4;
}

message Ignore {
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    FeedItem target                = 4;
}

message Flag {
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    FeedItem target                = 4;
}

message Join {
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    repeated Like likes            = 4;
}

message Announce {
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
}

message Leave {
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    repeated Like likes            = 4;
}

message Text {
    string block                   = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    string body                    = 4;
    repeated Comment comments      = 5;
    repeated Like likes            = 6;
}

message TextList {
    repeated Text items = 1;
}

message File {
    int32 index                  = 1;
    FileIndex file               = 2;
    map<string, FileIndex> links = 3;
}

message Files {
    string block                   = 1;
    string target                  = 2;
	string data                    = 10;
    google.protobuf.Timestamp date = 3;
    User user                      = 4;
    string caption                 = 5;
    repeated File files            = 6;
    repeated Comment comments      = 7;
    repeated Like likes            = 8;
    repeated string threads        = 9;
}

message FilesList {
    repeated Files items = 1;
}

message Comment {
	option deprecated = true;
    string id                      = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    string body                    = 4;
    FeedItem target                = 5;
}

message CommentList {
	option deprecated = true;
    repeated Comment items = 1;
}

message Like {
    string id                      = 1;
    google.protobuf.Timestamp date = 2;
    User user                      = 3;
    FeedItem target                = 4;
}

message LikeList {
    repeated Like items = 1;
}

// UPDATES //

message AccountUpdate {
    string id  = 1;
    string key = 2 [deprecated = true];
    Type type  = 3;

    enum Type {
        THREAD_ADDED         = 0;
        THREAD_REMOVED       = 1;
        ACCOUNT_PEER_ADDED   = 2;
        ACCOUNT_PEER_REMOVED = 3;
    }
}

// SUMMARY //

message Summary {
    string id                = 1;
    string address           = 2;
    int32 account_peer_count = 3;
    int32 thread_count       = 4;
    int32 files_count        = 5;
    int32 contact_count      = 6;
}

// LOGS //

message LogLevel {
    map<string, Level> systems = 1;

    enum Level {
        CRITICAL = 0;
        ERROR    = 1;
        WARNING  = 2;
        NOTICE   = 3;
        INFO     = 4;
        DEBUG    = 5;
    }
}

// PRIMITIVES

message Strings {
    repeated string values = 1;
}