Skip to content

Commit

Permalink
fix(rn): docker-compose go bin pkg
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Dec 11, 2018
1 parent 47e003b commit 64f01ec
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 35 deletions.
2 changes: 0 additions & 2 deletions client/react-native/Dockerfile
Expand Up @@ -31,5 +31,3 @@ VOLUME /go/src

CMD cd /go/src/berty.tech/core \
&& make dev RUN_DAEMON_OPTS="--log-level=debug --jaeger-address=react-native_tracer-service_1:6831"


2 changes: 1 addition & 1 deletion client/react-native/Makefile
Expand Up @@ -192,7 +192,7 @@ webapp.logs:

webapp.open:
@GQL_PORTS=`docker ps -f name=react-native_core-service --format "{{.Ports}}" | \
awk 'match($$0,/:8[0-9]{3}->/) {print substr($$0,RSTART+1,RLENGTH-3)}'`; \
awk 'match($$0,/:8[0-]{3}->/) {print substr($$0,RSTART+1,RLENGTH-3)}'`; \
COUNT=$$(echo "$$GQL_PORTS" | sed '/^\s*$$/d' | wc -l | tr -d ' '); \
if [[ $$(docker ps -f name=react-native_tracer-service -q) ]]; then \
COUNT=$$((COUNT+1)); \
Expand Down
35 changes: 34 additions & 1 deletion client/react-native/common/graphql/queries/Conversation.js
Expand Up @@ -4,8 +4,41 @@ import { merge } from '../../helpers'

const query = graphql`
query ConversationQuery($id: ID!) {
GetConversation(id: $id) {
Conversation(id: $id) {
id
createdAt
updatedAt
readAt
title
topic
members {
id
createdAt
updatedAt
status
contact {
id
createdAt
updatedAt
sigchain
status
devices {
id
createdAt
updatedAt
name
status
apiVersion
contactId
}
displayName
displayStatus
overrideDisplayName
overrideDisplayStatus
}
conversationId
contactId
}
...Conversation
}
}
Expand Down
Expand Up @@ -8,13 +8,10 @@ export default context => ({
updater &&
(async (store, data) => {
if (data.EventStream.kind === 301) {
console.log('new invite', data.EventStream)
const conversation = await context.queries.Conversation.fetch({
updater(store, { id: data.EventStream.conversationId })
await context.queries.Conversation.fetch({
id: data.EventStream.conversationId,
})

console.log('ConversationInvite: conversation: ', conversation)
return updater && updater(store, conversation)
}
}),
}),
Expand Down
2 changes: 2 additions & 0 deletions client/react-native/docker-compose.yml
Expand Up @@ -37,3 +37,5 @@ services:
- tracer-service
volumes:
- $GOPATH/src:/go/src
- /tmp/go/pkg:/go/pkg

20 changes: 10 additions & 10 deletions core/api/client/jsonclient/berty.node.service.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 39 additions & 6 deletions core/api/node/graphql/resolver.go
Expand Up @@ -250,9 +250,9 @@ func (r *queryResolver) Node(ctx context.Context, id string) (models.Node, error
case "contact":
return r.Contact(ctx, &entity.Contact{ID: id})
case "conversation":
return r.GetConversation(ctx, id)
return r.client.Conversation(ctx, &entity.Conversation{ID: id})
case "conversation_member":
return r.GetConversationMember(ctx, id)
return r.client.ConversationMember(ctx, &entity.ConversationMember{ID: id})
case "event":
return r.GetEvent(ctx, id)
default:
Expand Down Expand Up @@ -543,11 +543,44 @@ func (r *mutationResolver) ConversationRead(ctx context.Context, id string) (*en
})
}

func (r *queryResolver) GetConversation(ctx context.Context, id string) (*entity.Conversation, error) {
return r.client.GetConversation(ctx, &gql.Node{ID: strings.SplitN(id, ":", 2)[1]})
func (r *queryResolver) Conversation(ctx context.Context, id string, createdAt, updatedAt, readAt *time.Time, title, topic string, members []*entity.ConversationMember) (*entity.Conversation, error) {
if id != "" {
id = strings.SplitN(id, ":", 2)[1]
}
if members != nil && len(members) > 0 {
for i := range members {
if members[i] == nil || members[i].ID == "" {
continue
}
members[i].ID = strings.SplitN(members[i].ID, ":", 2)[1]
}
}

return r.client.Conversation(ctx, &entity.Conversation{
ID: id,
})
}
func (r *queryResolver) GetConversationMember(ctx context.Context, id string) (*entity.ConversationMember, error) {
return r.client.GetConversationMember(ctx, &gql.Node{ID: strings.SplitN(id, ":", 2)[1]})
func (r *queryResolver) ConversationMember(ctx context.Context, id string, createAt, updatedAt *time.Time, status *int32, contact *entity.Contact, conversationId, contactId string) (*entity.ConversationMember, error) {
if id != "" {
id = strings.SplitN(id, ":", 2)[1]
}
if contact.ID != "" {
contact.ID = strings.SplitN(contact.ID, ":", 2)[1]
}
if contact.Devices != nil && len(contact.Devices) != 0 {
for i := range contact.Devices {
contact.Devices[i].ID = strings.SplitN(contact.Devices[i].ID, ":", 2)[1]
}
}
if conversationId != "" {
conversationId = strings.SplitN(conversationId, ":", 2)[1]
}
if contactId != "" {
contactId = strings.SplitN(contactId, ":", 2)[1]
}
return r.client.ConversationMember(ctx, &entity.ConversationMember{
ID: id,
})
}
func (r *queryResolver) DeviceInfos(ctx context.Context, T bool) (*deviceinfo.DeviceInfos, error) {
return r.client.DeviceInfos(ctx, &node.Void{T: true})
Expand Down
4 changes: 2 additions & 2 deletions core/api/node/service.proto
Expand Up @@ -88,10 +88,10 @@ service Service {
rpc ConversationAddMessage (ConversationAddMessageInput) returns (berty.p2p.Event) {
option (gql.graphql_type) = "Mutation";
};
rpc GetConversation (gql.Node) returns (berty.entity.Conversation) {
rpc Conversation (berty.entity.Conversation) returns (berty.entity.Conversation) {
option (gql.graphql_type) = "Query";
};
rpc GetConversationMember (gql.Node) returns (berty.entity.ConversationMember) {
rpc ConversationMember (berty.entity.ConversationMember) returns (berty.entity.ConversationMember) {
option (gql.graphql_type) = "Query";
};
rpc ConversationRead (gql.Node) returns (berty.entity.Conversation) {
Expand Down
16 changes: 8 additions & 8 deletions core/node/nodeapi.go
Expand Up @@ -510,35 +510,35 @@ func (n *Node) ConversationAddMessage(ctx context.Context, input *node.Conversat
}

// GetConversation implements berty.node.GetConversation
func (n *Node) GetConversation(ctx context.Context, input *gql.Node) (*entity.Conversation, error) {
func (n *Node) Conversation(ctx context.Context, input *entity.Conversation) (*entity.Conversation, error) {
var span opentracing.Span
span, ctx = tracing.EnterFunc(ctx, input)
defer span.Finish()
n.handleMutex(ctx)()

sql := n.sql(ctx)
conversation := &entity.Conversation{}
if err := sql.Where(input).First(conversation).Error; err != nil {
output := &entity.Conversation{}
if err := sql.Where(input).First(output).Error; err != nil {
return nil, errorcodes.ErrDbNothingFound.Wrap(err)
}

return conversation, nil
return output, nil
}

// GetConversationMember implements berty.node.GetConversationMember
func (n *Node) GetConversationMember(ctx context.Context, input *gql.Node) (*entity.ConversationMember, error) {
func (n *Node) ConversationMember(ctx context.Context, input *entity.ConversationMember) (*entity.ConversationMember, error) {
var span opentracing.Span
span, ctx = tracing.EnterFunc(ctx, input)
defer span.Finish()
n.handleMutex(ctx)()

sql := n.sql(ctx)
conversationMember := &entity.ConversationMember{}
if err := sql.Where(input).First(conversationMember).Error; err != nil {
output := &entity.ConversationMember{}
if err := sql.Where(input).First(output).Error; err != nil {
return nil, errorcodes.ErrDbNothingFound.Wrap(err)
}

return conversationMember, nil
return output, nil
}

func (n *Node) DebugPing(ctx context.Context, input *node.PingDestination) (*node.Void, error) {
Expand Down

0 comments on commit 64f01ec

Please sign in to comment.