// protoc -I=. -I=$GOPATH/src --go_out=plugins=grpc:. *.proto
syntax = "proto3";

package dtalk.proto;
option go_package = "proto";

enum Device {
    Android = 0;
    IOS = 1;
}

message Login {
    Device device = 1;
    string username = 2;
}

// event define
enum EventType {
    commonMsg = 0;
    commonMsgAck = 1;
    Notice = 2;
}

message Proto {
    EventType eventType = 1;
    bytes body = 2;
}

// common msg define
enum MsgType {
    System          = 0;
    Text            = 1;
    Audio           = 2;
    Image           = 3;
    Video           = 4;
    File            = 5;
    Card            = 6;
    Alert           = 7;
    Forward         = 8;
}

message CommonMsg {
    int32 channelType = 1;
    int64 logId = 2;
    string msgId = 3;
    string from = 4;
    string target = 5;
    int32 msgType = 6;
    bytes msg = 7;
    uint64 datetime = 8;
    Source source = 9;
}

message Source {
    int32 channelType=1;
    SourceUser from=2;
    SourceUser target=3;
}

message SourceUser {
    string id=1;
    string name=2;
}

message CommonMsgAck {
    int64 logId = 2;
    uint64 datetime = 8;
}

message EncryptMsg {
    string content = 1;
}

message TextMsg {
    string content = 1;
}

message AudioMsg {
    string mediaUrl = 1;
    int32 time = 2;
}

message ImageMsg {
    string mediaUrl = 1;
    int32 height = 2;
    int32 width = 3;
}

message VideoMsg {
    string mediaUrl = 1;
    int32 time = 2;
    int32 height = 3;
    int32 width = 4;
}

message FileMsg {
    string mediaUrl = 1;
    string name = 2;
    string md5 = 3;
    int64 size = 4;
}

message CardMsg {
    string bank = 1;
    string name = 2;
    string account = 3;
}

message AlertMsg {
    AlertType type = 1;
    bytes body = 2;
}

message ForwardMsg {
    repeated ForwardItem items = 1;
}

message ForwardItem {
    string avatar=1;
    string name=2;
    int32 msgType=3;
    bytes msg=4;
    uint64 datetime=5;
}

enum AlertType {
    UpdateGroupNameAlert = 0;
    SignInGroupAlert = 1;
    SignOutGroupAlert = 2;
    KickOutGroupAlert = 3;
    DeleteGroupAlert = 4;
    UpdateGroupMutedAlert = 5;
    UpdateGroupMemberMutedAlert = 6;
    UpdateGroupOwnerAlert = 7;
    CommonMsg = 8;
}

message AlertUpdateGroupName {
    int64 group = 1;
    string operator = 2;
    string name = 3;
}

message AlertSignInGroup {
    int64 group = 1;
    string inviter = 2;
    repeated string members = 3;
}

message AlertSignOutGroup {
    int64 group = 1;
    string operator = 2;
}

message AlertKickOutGroup {
    int64 group = 1;
    string operator = 2;
    repeated string members = 3;
}

message AlertDeleteGroup {
    int64 group = 1;
    string operator = 2;
}

message AlertUpdateGroupMuted {
    int64 group = 1;
    string operator = 2;
    proto.MuteType type = 3;
}

message AlertUpdateGroupMemberMutedTime {
    int64 group = 1;
    string operator = 2;
    repeated string members = 3;
}

message AlertUpdateGroupOwner {
    int64 group = 1;
    string newOwner = 2;
}

//alert msg define
message NotifyMsg {
    ActionType action = 1;
    bytes body = 2;
}

enum ActionType {
    Received = 0;
    SignInGroup = 10;
    SignOutGroup = 11;
    DeleteGroup = 12;
    //
    UpdateGroupJoinType = 20;
    UpdateGroupFriendType = 21;
    UpdateGroupMuteType = 22;
    UpdateGroupMemberType = 23;
    UpdateGroupMemberMuteTime = 24;
    UpdateGroupName = 25;
    UpdateGroupAvatar = 26;
}

message ActionReceived {
    repeated uint64 logs = 1;
}

message ActionSignInGroup {
    repeated string uid = 1;
    int64 group = 2;
    uint64 time = 3;
}

message ActionSignOutGroup {
    repeated string uid = 1;
    int64 group = 2;
    uint64 time = 3;
}

message ActionDeleteGroup {
    int64 group = 1;
    uint64 time = 2;
}

enum JoinType {
    JoinAllow = 0;
    JoinDeny = 1;
}

message ActionUpdateGroupJoinType {
    int64 group = 1;
    JoinType type = 2;
    uint64 time = 3;
}

enum FriendType {
    FriendAllow = 0;
    FriendDeny = 1;
}

message ActionUpdateGroupFriendType {
    int64 group = 1;
    FriendType type = 2;
    uint64 time = 3;
}

enum MuteType {
    MuteAllow = 0;
    MuteDeny = 1;
}

message ActionUpdateGroupMuteType {
    int64 group = 1;
    MuteType type = 2;
    uint64 time = 3;
}

enum MemberType {
    Normal = 0;
    Admin = 1;
    Owner = 2;
}

message ActionUpdateGroupMemberType {
    int64 group = 1;
    string uid = 2;
    MemberType type = 3;
    uint64 time = 4;
}

message ActionUpdateGroupMemberMuteTime {
    int64 group = 1;
    repeated string uid = 2;
    int64 muteTime = 3;
    uint64 time = 4;
}

message ActionUpdateGroupName {
    int64 group = 1;
    string name = 2;
    uint64 time = 3;
}

message ActionUpdateGroupAvatar {
    int64 group = 1;
    string avatar = 2;
    uint64 time = 3;
}
