douglara / woofed-crm

136 stars 37 forks source link

Add import evolution_api messages #251

Closed YukioArie closed 8 months ago

douglara commented 9 months ago

Acho que tem algum problema no recebimento

https://github.com/douglara/woofed-crm/assets/14988496/b28a4df3-a6f9-41b6-8efa-bfc3047d1919

Segue os logs:

| 2024-02-09T11:00:32.211Z pid=20265 tid=b2l class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=4d4d13e713414c8b157b6363 elapsed=0.003 INFO: done
08:00:37 web.1     | Started POST "/apps/evolution_apis/webhooks" for 20.121.47.79 at 2024-02-09 08:00:37 -0300
08:00:37 web.1     | Cannot render console from 20.121.47.79! Allowed networks: 127.0.0.0/127.255.255.255, ::1
08:00:37 web.1     | Processing by Apps::EvolutionApisController#webhooks as HTML
08:00:37 web.1     |   Parameters: {"event"=>"presence.update", "instance"=>"023084d0184e7800cb81", "data"=>{"id"=>"554196910256@s.whatsapp.net", "presences"=>{"554196910256@s.whatsapp.net"=>{"lastKnownPresence"=>"composing"}}}, "destination"=>"https://weak-deer-44.hooks.n8n.cloud/apps/evolution_apis/webhooks", "date_time"=>"2024-02-09T08:00:36.839Z", "sender"=>"554196639923@s.whatsapp.net", "server_url"=>"https://evolution-api-staging.server3.woofedcrm.com", "apikey"=>"16cd00c39cb489cd0317", "evolution_api"=>{"instance"=>"023084d0184e7800cb81"}}
08:00:37 web.1     | Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 431)
08:00:37 web.1     | 
08:00:37 web.1     | 
08:00:37 sidekiq.1 | 2024-02-09T11:00:37.008Z pid=20265 tid=bhx class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=3b306e390abfabea7833b60b INFO: start
08:00:37 sidekiq.1 | 2024-02-09T11:00:37.012Z pid=20265 tid=bhx class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=3b306e390abfabea7833b60b elapsed=0.003 INFO: done
08:00:38 web.1     | Started POST "/apps/evolution_apis/webhooks" for 20.121.47.79 at 2024-02-09 08:00:38 -0300
08:00:38 web.1     | Cannot render console from 20.121.47.79! Allowed networks: 127.0.0.0/127.255.255.255, ::1
08:00:38 web.1     | Processing by Apps::EvolutionApisController#webhooks as HTML
08:00:38 web.1     |   Parameters: {"event"=>"messages.upsert", "instance"=>"023084d0184e7800cb81", "data"=>{"key"=>{"remoteJid"=>"554196910256@s.whatsapp.net", "fromMe"=>false, "id"=>"3A15F3E65E4E218C2A0A"}, "pushName"=>"Douglas Lara", "message"=>{"conversation"=>"Oii", "messageContextInfo"=>{"deviceListMetadata"=>{"senderKeyHash"=>"0tMRWY8+LfrmeA==", "senderTimestamp"=>"1706526347", "recipientKeyHash"=>"pLk/6pJJZIzrSg==", "recipientTimestamp"=>"1707476284"}, "deviceListMetadataVersion"=>2}}, "messageType"=>"conversation", "messageTimestamp"=>1707476437, "owner"=>"023084d0184e7800cb81", "source"=>"ios"}, "destination"=>"https://weak-deer-44.hooks.n8n.cloud/apps/evolution_apis/webhooks", "date_time"=>"2024-02-09T08:00:38.055Z", "sender"=>"554196639923@s.whatsapp.net", "server_url"=>"https://evolution-api-staging.server3.woofedcrm.com", "apikey"=>"16cd00c39cb489cd0317", "evolution_api"=>{"instance"=>"023084d0184e7800cb81"}}
08:00:38 web.1     | Completed 200 OK in 2ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 541)
08:00:38 web.1     | 
08:00:38 web.1     | 
08:00:38 sidekiq.1 | 2024-02-09T11:00:38.344Z pid=20265 tid=b2l class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=f5f89e2abd3cccc2e54b0827 INFO: start
08:00:38 sidekiq.1 | 2024-02-09T11:00:38.356Z pid=20265 tid=b2l class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=f5f89e2abd3cccc2e54b0827 elapsed=0.012 INFO: done
08:00:38 web.1     | Started POST "/apps/evolution_apis/webhooks" for 20.121.47.79 at 2024-02-09 08:00:38 -0300
08:00:38 web.1     | Cannot render console from 20.121.47.79! Allowed networks: 127.0.0.0/127.255.255.255, ::1
08:00:38 web.1     | Processing by Apps::EvolutionApisController#webhooks as HTML
08:00:38 web.1     |   Parameters: {"event"=>"contacts.update", "instance"=>"023084d0184e7800cb81", "data"=>[{"id"=>"554196910256@s.whatsapp.net", "profilePictureUrl"=>"https://pps.whatsapp.net/v/t61.24694-24/218088560_1343083402861493_7003699211785604252_n.jpg?ccb=11-4&oh=01_AdRQK8U-DUhXnw7BaCsVz0iXrSfkeqgtSZ3xG967hQi9TQ&oe=65D3246C&_nc_sid=e6ed6c&_nc_cat=110", "owner"=>"023084d0184e7800cb81"}], "destination"=>"https://weak-deer-44.hooks.n8n.cloud/apps/evolution_apis/webhooks", "date_time"=>"2024-02-09T08:00:38.085Z", "sender"=>"554196639923@s.whatsapp.net", "server_url"=>"https://evolution-api-staging.server3.woofedcrm.com", "apikey"=>"16cd00c39cb489cd0317", "evolution_api"=>{"instance"=>"023084d0184e7800cb81"}}
08:00:38 web.1     | Started POST "/apps/evolution_apis/webhooks" for 20.121.47.79 at 2024-02-09 08:00:38 -0300
08:00:38 web.1     | Cannot render console from 20.121.47.79! Allowed networks: 127.0.0.0/127.255.255.255, ::1
08:00:38 sidekiq.1 | 2024-02-09T11:00:38.473Z pid=20265 tid=ael class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=9843bfb07651afcada74ced6 INFO: start
08:00:38 web.1     | Processing by Apps::EvolutionApisController#webhooks as HTML
08:00:38 web.1     |   Parameters: {"event"=>"chats.update", "instance"=>"023084d0184e7800cb81", "data"=>[{"id"=>"554196910256@s.whatsapp.net", "owner"=>"554196639923@s.whatsapp.net"}], "destination"=>"https://weak-deer-44.hooks.n8n.cloud/apps/evolution_apis/webhooks", "date_time"=>"2024-02-09T08:00:38.057Z", "sender"=>"554196639923@s.whatsapp.net", "server_url"=>"https://evolution-api-staging.server3.woofedcrm.com", "apikey"=>"16cd00c39cb489cd0317", "evolution_api"=>{"instance"=>"023084d0184e7800cb81"}}
08:00:38 web.1     | Completed 200 OK in 9ms (Views: 0.3ms | ActiveRecord: 0.0ms | Allocations: 1425)
08:00:38 web.1     | 
08:00:38 web.1     | 
08:00:38 web.1     | Completed 200 OK in 6ms (Views: 1.1ms | ActiveRecord: 0.0ms | Allocations: 422)
08:00:38 web.1     | 
08:00:38 sidekiq.1 | 2024-02-09T11:00:38.487Z pid=20265 tid=am5 class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=5879d960e38afe55ef3434f9 INFO: start
08:00:38 web.1     | 
08:00:38 sidekiq.1 | 2024-02-09T11:00:38.488Z pid=20265 tid=ael class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=9843bfb07651afcada74ced6 elapsed=0.015 INFO: done
08:00:38 sidekiq.1 | 2024-02-09T11:00:38.495Z pid=20265 tid=am5 class=Accounts::Apps::EvolutionApis::Webhooks::ProcessWebhookWorker jid=5879d960e38afe55ef3434f9 elapsed=0.008 INFO: done
08:00:38 web.1     | Started POST "/apps/evolution_apis/webhooks" for 20.121.47.79 at 2024-02-09 08:00:38 -0300
08:00:38 web.1     | Cannot render console from 20.121.47.79! Allowed networks: 127.0.0.0/127.255.255.255, ::1
08:00:38 web.1     | Processing by Apps::EvolutionApisController#webhooks as HTML
08:00:38 web.1     |   Parameters: {"event"=>"contacts.update", "instance"=>"023084d0184e7800cb81", "data"=>{"id"=>"554196910256@s.whatsapp.net", "profilePictureUrl"=>"https://pps.whatsapp.net/v/t61.24694-24/218088560_1343083402861493_7003699211785604252_n.jpg?ccb=11-4&oh=01_AdRQK8U-DUhXnw7BaCsVz0iXrSfkeqgtSZ3xG967hQi9TQ&oe=65D3246C&_nc_sid=e6ed6c&_nc_cat=110", "owner"=>"023084d0184e7800cb81"}, "destination"=>"https://weak-deer-44.hooks.n8n.cloud/apps/evolution_apis/webhooks", "date_time"=>"2024-02-09T08:00:38.104Z", "sender"=>"554196639923@s.whatsapp.net", "server_url"=>"https://evolution-api-staging.server3.woofedcrm.com", "apikey"=>"16cd00c39cb489cd0317", "evolution_api"=>{"instance"=>"023084d0184e7800cb81"}}
08:00:38 web.1     | Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 436)
08:00:38 web.1     | 
YukioArie commented 9 months ago

O erro de não receber as mensagens era que eu estava criando o event de contato com o numeor do campo "sender": "5522998813788@s.whatsapp.net", mas na verdade o correto é pegar o numero do campo "remoteJid": "5522998980131@s.whatsapp.net". Como eu fiz o teste enviando uma mensagem para mim msm, esses dois campo eram iguais e eu acabei me confundindo 😄 , mas agora tá funcionando perfeitamente.

YukioArie commented 9 months ago

@douglara q estranho, depois desses ultimos commits q fiz, ele n passou pelo teste do github, mas passou pelo teste que rodei com bundle exec rspec na minha maquina. Fora que os errors que estão dando n fazem sentido. image