Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make API messages names be the same as their event #89

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions api/protocol/protocoltypes.proto
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,19 @@ enum EventType {
// EventTypeAccountContactRequestReferenceReset indicates the payload includes that the account has a new contact request rendezvous seed
EventTypeAccountContactRequestReferenceReset = 105;

// EventTypeAccountContactRequestEnqueued indicates the payload includes that the account will attempt to send a new contact request
// EventTypeAccountContactRequestOutgoingEnqueued indicates the payload includes that the account will attempt to send a new contact request
EventTypeAccountContactRequestOutgoingEnqueued = 106;

// EventTypeAccountContactRequestSent indicates the payload includes that the account has sent a contact request
// EventTypeAccountContactRequestOutgoingSent indicates the payload includes that the account has sent a contact request
EventTypeAccountContactRequestOutgoingSent = 107;

// EventTypeAccountContactRequestReceived indicates the payload includes that the account has received a contact request
// EventTypeAccountContactRequestIncomingReceived indicates the payload includes that the account has received a contact request
EventTypeAccountContactRequestIncomingReceived = 108;

// EventTypeAccountContactRequestIncomingDiscarded indicates the payload includes that the account has ignored a contact request
EventTypeAccountContactRequestIncomingDiscarded = 109;

// EventTypeAccountContactRequestAccepted indicates the payload includes that the account has accepted a contact request
// EventTypeAccountContactRequestIncomingAccepted indicates the payload includes that the account has accepted a contact request
EventTypeAccountContactRequestIncomingAccepted = 110;

// EventTypeAccountContactBlocked indicates the payload includes that the account has blocked a contact
Expand Down Expand Up @@ -403,27 +403,27 @@ message EventContext {
reserved 4; // repeated bytes attachment_cids = 4 [(gogoproto.customname) = "AttachmentCIDs"];
}

// AppMetadata is an app defined message, accessible to future group members
message AppMetadata {
// GroupMetadataPayloadSent is an app defined message, accessible to future group members
message GroupMetadataPayloadSent {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

// message is the payload
bytes message = 2;
}

// ContactAddAliasKey is an event type where ones shares their alias public key
message ContactAddAliasKey {
// ContactAliasKeyAdded is an event type where ones shares their alias public key
message ContactAliasKeyAdded {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

// alias_pk is the alias key which will be used to verify a contact identity
bytes alias_pk = 2 [(gogoproto.customname) = "AliasPK"];
}

// GroupAddMemberDevice is an event which indicates to a group a new device (and eventually a new member) is joining it
// When added on AccountGroup, this event should be followed by appropriate GroupAddMemberDevice and GroupAddDeviceChainKey events
message GroupAddMemberDevice {
// GroupMemberDeviceAdded is an event which indicates to a group a new device (and eventually a new member) is joining it
// When added on AccountGroup, this event should be followed by appropriate GroupMemberDeviceAdded and GroupDeviceChainKeyAdded events
message GroupMemberDeviceAdded {
// member_pk is the member sending the event
bytes member_pk = 1 [(gogoproto.customname) = "MemberPK"];

Expand All @@ -443,8 +443,8 @@ message DeviceChainKey {
uint64 counter = 2;
}

// GroupAddDeviceChainKey is an event which indicates to a group member a device chain key
message GroupAddDeviceChainKey {
// GroupDeviceChainKeyAdded is an event which indicates to a group member a device chain key
message GroupDeviceChainKeyAdded {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

Expand All @@ -455,8 +455,8 @@ message GroupAddDeviceChainKey {
bytes payload = 3;
}

// MultiMemberGroupAddAliasResolver indicates that a group member want to disclose their presence in the group to their contacts
message MultiMemberGroupAddAliasResolver {
// MultiMemberGroupAliasResolverAdded indicates that a group member want to disclose their presence in the group to their contacts
message MultiMemberGroupAliasResolverAdded {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

Expand All @@ -469,17 +469,17 @@ message MultiMemberGroupAddAliasResolver {
bytes alias_proof = 3;
}

// MultiMemberGrantAdminRole indicates that a group admin allows another group member to act as an admin
message MultiMemberGrantAdminRole {
// MultiMemberGroupAdminRoleGranted indicates that a group admin allows another group member to act as an admin
message MultiMemberGroupAdminRoleGranted {
// device_pk is the device sending the event, signs the message, must be the device of an admin of the group
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

// grantee_member_pk is the member public key of the member granted of the admin role
bytes grantee_member_pk = 2 [(gogoproto.customname) = "GranteeMemberPK"];
}

// MultiMemberInitialMember indicates that a member is the group creator, this event is signed using the group ID private key
message MultiMemberInitialMember {
// MultiMemberGroupInitialMemberAnnounced indicates that a member is the group creator, this event is signed using the group ID private key
message MultiMemberGroupInitialMemberAnnounced {
// member_pk is the public key of the member who is the group creator
bytes member_pk = 1 [(gogoproto.customname) = "MemberPK"];
}
Expand Down Expand Up @@ -511,7 +511,7 @@ message AccountGroupJoined {
Group group = 2;
}

// AccountGroupJoined indicates that the account has left a group
// AccountGroupLeft indicates that the account has left a group
message AccountGroupLeft {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];
Expand All @@ -526,13 +526,13 @@ message AccountContactRequestDisabled {
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];
}

// AccountContactRequestDisabled indicates that the account should be advertised on a public rendezvous point
// AccountContactRequestEnabled indicates that the account should be advertised on a public rendezvous point
message AccountContactRequestEnabled {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];
}

// AccountContactRequestDisabled indicates that the account should be advertised on different public rendezvous points
// AccountContactRequestReferenceReset indicates that the account should be advertised on different public rendezvous points
message AccountContactRequestReferenceReset {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];
Expand All @@ -542,10 +542,10 @@ message AccountContactRequestReferenceReset {
}

// This event should be followed by an AccountGroupJoined event
// This event should be followed by a GroupAddMemberDevice event within the AccountGroup
// This event should be followed by a GroupAddDeviceChainKey event within the AccountGroup
// AccountContactRequestEnqueued indicates that the account will attempt to send a contact request when a matching peer is discovered
message AccountContactRequestEnqueued {
// This event should be followed by a GroupMemberDeviceAdded event within the AccountGroup
// This event should be followed by a GroupDeviceChainKeyAdded event within the AccountGroup
// AccountContactRequestOutgoingEnqueued indicates that the account will attempt to send a contact request when a matching peer is discovered
message AccountContactRequestOutgoingEnqueued {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

Expand All @@ -559,17 +559,17 @@ message AccountContactRequestEnqueued {
bytes own_metadata = 4;
}

// AccountContactRequestSent indicates that the account has sent a contact request
message AccountContactRequestSent {
// AccountContactRequestOutgoingSent indicates that the account has sent a contact request
message AccountContactRequestOutgoingSent {
// device_pk is the device sending the account event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

// contact_pk is the contacted account
bytes contact_pk = 2 [(gogoproto.customname) = "ContactPK"];
}

// AccountContactRequestReceived indicates that the account has received a new contact request
message AccountContactRequestReceived {
// AccountContactRequestIncomingReceived indicates that the account has received a new contact request
message AccountContactRequestIncomingReceived {
// device_pk is the device sending the account event (which received the contact request), signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

Expand All @@ -585,8 +585,8 @@ message AccountContactRequestReceived {
bytes contact_metadata = 4;
}

// AccountContactRequestDiscarded indicates that a contact request has been refused
message AccountContactRequestDiscarded {
// AccountContactRequestIncomingDiscarded indicates that a contact request has been refused
message AccountContactRequestIncomingDiscarded {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

Expand All @@ -595,9 +595,9 @@ message AccountContactRequestDiscarded {
}

// This event should be followed by an AccountGroupJoined event
// This event should be followed by GroupAddMemberDevice and GroupAddDeviceChainKey events within the AccountGroup
// AccountContactRequestAccepted indicates that a contact request has been accepted
message AccountContactRequestAccepted {
// This event should be followed by GroupMemberDeviceAdded and GroupDeviceChainKeyAdded events within the AccountGroup
// AccountContactRequestIncomingAccepted indicates that a contact request has been accepted
message AccountContactRequestIncomingAccepted {
// device_pk is the device sending the event, signs the message
bytes device_pk = 1 [(gogoproto.customname) = "DevicePK"];

Expand Down
6 changes: 3 additions & 3 deletions contact_request_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (c *contactRequestsManager) metadataRequestEnqueued(ctx context.Context, ev
strings.TrimPrefix(evt.Metadata.EventType.String(), "EventType"), base64.RawURLEncoding.EncodeToString(evt.EventContext.GroupPK))
c.logger.Debug(traceName, tyber.FormatStepLogFields(ctx, []tyber.Detail{}, tyber.UpdateTraceName(traceName))...)

e := &protocoltypes.AccountContactRequestEnqueued{}
e := &protocoltypes.AccountContactRequestOutgoingEnqueued{}
if err := e.Unmarshal(evt.Event); err != nil {
return tyber.LogError(ctx, c.logger, "Failed to unmarshal event", err)
}
Expand All @@ -283,7 +283,7 @@ func (c *contactRequestsManager) metadataRequestEnqueued(ctx context.Context, ev
}

func (c *contactRequestsManager) metadataRequestSent(_ context.Context, evt *protocoltypes.GroupMetadataEvent) error {
e := &protocoltypes.AccountContactRequestSent{}
e := &protocoltypes.AccountContactRequestOutgoingSent{}
if err := e.Unmarshal(evt.Event); err != nil {
return errcode.ErrDeserialization.Wrap(err)
}
Expand All @@ -295,7 +295,7 @@ func (c *contactRequestsManager) metadataRequestSent(_ context.Context, evt *pro
}

func (c *contactRequestsManager) metadataRequestReceived(_ context.Context, evt *protocoltypes.GroupMetadataEvent) error {
e := &protocoltypes.AccountContactRequestReceived{}
e := &protocoltypes.AccountContactRequestIncomingReceived{}
if err := e.Unmarshal(evt.Event); err != nil {
return errcode.ErrDeserialization.Wrap(err)
}
Expand Down
4 changes: 2 additions & 2 deletions contact_request_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestContactRequestFlow(t *testing.T) {
continue
}

req := &protocoltypes.AccountContactRequestReceived{}
req := &protocoltypes.AccountContactRequestIncomingReceived{}
err = req.Unmarshal(evt.Event)

require.NoError(t, err)
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestContactRequestFlowWithoutIncoming(t *testing.T) {
continue
}

req := &protocoltypes.AccountContactRequestReceived{}
req := &protocoltypes.AccountContactRequestIncomingReceived{}
err = req.Unmarshal(evt.Event)

require.NoError(t, err)
Expand Down
Loading