fix: B2B "Skontaktuj się" now uses new conversation system
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

Changed B2B classified contact link from old messages_new to new
conversations page with ?new_to=USER_ID parameter. JS creates a
1:1 conversation via API and opens it, or opens existing one if
already present. Messages now visible in the conversations inbox.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-09 23:13:21 +02:00
parent 58485fc6c1
commit 67702a610c
3 changed files with 30 additions and 2 deletions

View File

@ -3160,6 +3160,34 @@
ConversationList.selectConversation(convId);
}
}
// If URL has ?new_to=<user_id>, open new message modal with pre-selected recipient
var newToParam = urlParams.get('new_to');
if (newToParam) {
var targetUserId = parseInt(newToParam);
if (targetUserId) {
// Check if conversation with this user already exists (1:1)
var existingConv = state.conversations.find(function (c) {
return !c.is_group && c.members && c.members.some(function (m) {
return m.user_id === targetUserId;
});
});
if (existingConv) {
ConversationList.selectConversation(existingConv.id);
} else {
// Open new message modal — create conversation via API, then open it
fetch('/api/conversations', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRFToken': window.__CSRF_TOKEN__ },
body: JSON.stringify({ member_ids: [targetUserId] })
}).then(function (r) { return r.json(); }).then(function (data) {
if (data.id) {
window.location.href = '/wiadomosci?conv=' + data.id;
}
}).catch(function () {});
}
}
}
}
if (document.readyState === 'loading') {

View File

@ -727,7 +727,7 @@
</svg>
<span id="interestBtnText">{% if user_interested %}Zainteresowany{% else %}Jestem zainteresowany{% endif %}</span>
</button>
<a href="{{ url_for('messages_new', to=classified.author_id, context_type='classified', context_id=classified.id) }}" class="btn btn-primary">Skontaktuj sie</a>
<a href="{{ url_for('messages.conversations_page') }}?new_to={{ classified.author_id }}" class="btn btn-primary">Skontaktuj sie</a>
</div>
{% endif %}
</div>

View File

@ -326,7 +326,7 @@ window.__CSRF_TOKEN__ = '{{ csrf_token() }}';
// Load conversations.js after data is set
(function() {
var s = document.createElement('script');
s.src = '{{ url_for("static", filename="js/conversations.js") }}?v=25';
s.src = '{{ url_for("static", filename="js/conversations.js") }}?v=26';
document.body.appendChild(s);
})();
{% endblock %}