मुख्य सामग्री पर जाएं

Messaging Endpoints

Messaging module real-time conversations, chat messages, push notifications, SMS/email delivery, WebSocket connections, private messaging, device registration, और texting providers को manage करता है। यह सभी ChurchApps applications में दोनों live streaming chat और asynchronous notifications के लिए उपयोग किया जाने वाला communication layer provide करता है।

Base path: /messaging

Conversations

Base path: /messaging/conversations

MethodPathAuthPermissionDescription
GET/timeline/ids?ids=JWTLoad conversations by comma-separated IDs with first/last messages
GET/messages/:contentType/:contentIdJWTLoad conversations for content with paginated messages (?page=&limit=)
GET/postsJWTGet post-type conversations for the current user's groups
GET/posts/group/:groupIdJWTGet post-type conversations for a specific group
GET/current/:churchId/:contentType/:contentIdPublicGet or create the current conversation for content (auto-decrypts contentId)
GET/:churchId/:contentType/:contentIdPublicLoad conversations by content type and ID
GET/:churchId/:idPublicLoad a single conversation by ID
POST/JWTCreate or update conversations (batch)
POST/startJWTStart a new conversation with an initial comment message
DELETE/:churchId/:idJWTDelete a conversation

Person notes access control

contentType: "person" वाली conversations (एक person record पर Notes tab) या contentType: "personConfidential" (Confidential Notes section) हर read और write path पर गated होती हैं, जिसमें above के अन्यथा-public routes शामिल हैं, जो इन content types के लिए 401 return करते हैं। person को MembershipApi People / Edit permission की आवश्यकता है; personConfidential को People / View Confidential Notes की आवश्यकता है। Scoped API keys के लिए, people:write दोनों actions को carry करता है (key का user अभी भी underlying role permission को hold करना चाहिए)।

उदाहरण: एक Conversation शुरू करना

POST /messaging/conversations/start
Authorization: Bearer <token>

{
"groupId": "group-123",
"contentType": "group",
"contentId": "group-123",
"title": "Weekly Discussion",
"comment": "Welcome to this week's discussion thread!"
}
{
"id": "conv-456",
"churchId": "church-789",
"contentType": "group",
"contentId": "group-123",
"title": "Weekly Discussion",
"dateCreated": "2026-02-17T10:00:00.000Z",
"visibility": "public",
"allowAnonymousPosts": false,
"groupId": "group-123"
}

Messages

Base path: /messaging/messages

MethodPathAuthPermissionDescription
GET/conversation/:conversationIdJWTLoad all messages for a conversation
GET/catchup/:churchId/:conversationIdPublicLoad all messages for a conversation (public catchup for live chat)
GET/:churchId/:idPublicLoad a single message by ID
POST/JWTSave messages (batch). Sends real-time updates and triggers notifications
POST/sendPublicSend messages (batch, public). Sends real-time updates via WebSocket and triggers notifications
POST/setCalloutJWT(legacy) Broadcast a callout message in real time. No active client; live stream chat no longer renders callouts
DELETE/:churchId/:idJWTDelete a message and broadcast the deletion in real time

उदाहरण: एक Message भेजना

POST /messaging/messages/send

[
{
"churchId": "church-789",
"conversationId": "conv-456",
"personId": "person-123",
"displayName": "John Smith",
"content": "Hello everyone!",
"messageType": "comment"
}
]
[
{
"id": "msg-001",
"churchId": "church-789",
"conversationId": "conv-456",
"personId": "person-123",
"displayName": "John Smith",
"timeSent": "2026-02-17T10:05:00.000Z",
"content": "Hello everyone!",
"messageType": "comment"
}
]

Private Messages

Base path: /messaging/privatemessages

MethodPathAuthPermissionDescription
GET/JWTLoad all private messages for the current user (includes last message per conversation, marks all as read)
GET/existing/:personIdJWTFind an existing private conversation with a specific person
GET/:idJWTLoad a private message by ID (clears notification if addressed to current user)
POST/JWTSend private messages (batch). Triggers push notification to recipient

Notifications

Base path: /messaging/notifications

MethodPathAuthPermissionDescription
GET/unreadCountJWTGet unread notification count for the current user
GET/myJWTLoad all notifications for the current user (marks all as read)
GET/tmpEmailPublicTrigger daily email notification digest (debug/cron endpoint)
GET/:churchId/person/:personIdJWTLoad notifications for a specific person
GET/:churchId/:idJWTLoad a notification by ID
POST/JWTCreate or update notifications (batch)
POST/createJWTCreate notifications for multiple people. Body: { peopleIds, contentType, contentId, message, link }
POST/markRead/:churchId/:personIdJWTMark all notifications as read for a person
POST/sendTestJWTSend a test push notification. Body: { personId, title }
POST/pingPublicCreate a notification from an external trigger. Body: { personId, churchId, contentType, contentId, message, triggeredByPersonId }
DELETE/:churchId/:idJWTDelete a notification

उदाहरण: Notifications बनाना

POST /messaging/notifications/create
Authorization: Bearer <token>

{
"peopleIds": ["person-123", "person-456"],
"contentType": "group",
"contentId": "group-789",
"message": "New event posted in your group",
"link": "/groups/group-789"
}

Notification Preferences

Base path: /messaging/notificationpreferences

Standard CRUD extend करता है। Base class POST / provide करता है (create या update, कोई permission की आवश्यकता नहीं)।

MethodPathAuthPermissionDescription
POST/JWTCreate or update notification preferences (from CRUD base class)
GET/myJWTLoad notification preferences for the current user (auto-creates defaults if none exist)

Connections

Base path: /messaging/connections

Chat, group conversations, private messages, और live streaming के लिए WebSocket/real-time connections को manage करता है। Real-time Architecture देखें end-to-end protocol के लिए।

MethodPathAuthPermissionDescription
GET/:churchId/:conversationIdPublicLoad all connections for a conversation
POST/PublicRegister connections (batch). Triggers an attendance broadcast on the conversation. Body items: { churchId, conversationId, socketId, displayName?, personId? }
POST/setNamePublicUpdate the display name for a connection by socket ID. Body: { socketId, name }
DELETE/:churchId/:conversationId/:socketIdPublicDrop a connection from a conversation. Triggers an attendance broadcast
POST/tmpSendAlertPublicSend a notification alert to a person's connections. Body: { churchId, personId }

Devices

Base path: /messaging/devices

Push notifications और content pairing के लिए device registration को manage करता है (उदाहरण के लिए, TV displays पर Lessons app)।

MethodPathAuthPermissionDescription
POST/enrollJWTEnroll या update एक device (mobile push registration)। FCM token या device ID द्वारा match करता है
POST/enrollAnonPublicEnroll एक anonymous device और एक 4-character pairing code generate करें
POST/PublicSave devices (batch)
GET/pair/:pairingCodeJWTPair एक device अपने pairing code का उपयोग करके। Optional ?contentType=&contentId= content assign करने के लिए
GET/status/:deviceIdPublicCheck pairing status of एक device
GET/:churchIdJWTLoad सभी devices एक church के लिए
GET/:churchId/person/:personIdJWTLoad सभी devices एक person के लिए
GET/:churchId/:idJWTLoad एक device by ID
DELETE/:churchId/:idJWTDelete एक device

उदाहरण: एक Device को Enroll करना

POST /messaging/devices/enroll
Authorization: Bearer <token>

{
"fcmToken": "firebase-token-abc123",
"appName": "B1Mobile",
"label": "John's iPhone",
"deviceInfo": "iOS 17, iPhone 15"
}
{
"id": "device-001",
"churchId": "church-789",
"fcmToken": "firebase-token-abc123",
"appName": "B1Mobile",
"label": "John's iPhone",
"registrationDate": "2026-02-17T10:00:00.000Z",
"lastActiveDate": "2026-02-17T10:00:00.000Z"
}

Device Contents

Base path: /messaging/devicecontents

Paired devices के लिए content assignments को manage करता है (उदाहरण के लिए, कौन सा lesson एक TV पर display किया जाता है)।

MethodPathAuthPermissionDescription
GET/deviceId/:deviceIdJWTLoad content assignments एक device के लिए
POST/JWTSave device content assignments (batch)
DELETE/:idJWTDelete एक device content assignment

Texting

Base path: /messaging/texting

SMS texting providers, group text messaging, और delivery tracking को manage करता है।

MethodPathAuthPermissionDescription
GET/providersJWTLoad texting providers church के लिए (credentials को mask किए जाते हैं)
GET/preview/:groupIdJWTPreview recipients एक group text के लिए (eligible, opted-out, no-phone counts)
GET/sentJWTLoad सभी sent text message records church के लिए
GET/sent/:id/detailsJWTLoad एक sent text per-recipient delivery logs के साथ
POST/providersJWTSave texting providers (batch)। API credentials को encrypt करता है
POST/sendJWTSend एक SMS को group के सभी eligible members को। Body: { groupId, message }
POST/sendPersonJWTSend एक SMS को single person को। Body: { personId, phoneNumber, message }
DELETE/providers/:idJWTDelete एक texting provider

उदाहरण: Group Text भेजना

POST /messaging/texting/send
Authorization: Bearer <token>

{
"groupId": "group-123",
"message": "Reminder: Service starts at 10 AM this Sunday!"
}
{
"totalMembers": 50,
"recipientCount": 42,
"successCount": 40,
"failCount": 2,
"optedOutCount": 5,
"noPhoneCount": 3
}

Email Templates

Base path: /messaging/emailTemplates

Reusable email templates और groups को templated emails भेजने को manage करता है।

MethodPathAuthPermissionDescription
GET/JWTLoad सभी email templates church के लिए
GET/:idJWTLoad एक single email template by ID
GET/preview/:groupIdJWTPreview email delivery एक group के लिए (eligible recipient count, members with no email)
POST/JWTCreate या update email templates (batch)
POST/sendJWTSend एक templated email को group के सभी members को। Body: { groupId, subject, htmlContent }
DELETE/:idJWTDelete एक email template

उदाहरण: Group को Email भेजना

POST /messaging/emailTemplates/send
Authorization: Bearer <token>

{
"groupId": "group-123",
"subject": "This Week's Update - {{churchName}}",
"htmlContent": "<p>Hello {{firstName}},</p><p>Here's what's happening this week...</p>"
}
{
"totalMembers": 50,
"recipientCount": 45,
"successCount": 44,
"failCount": 1,
"noEmailCount": 5
}

Supported merge fields: {{firstName}}, {{lastName}}, {{displayName}}, {{email}}, {{churchName}}

Blocked IPs

Base path: /messaging/blockedips

(legacy) Live streaming chat के लिए IP-blocking। B1App client अब POST / को call नहीं करता है — IP blocking को unified-delivery migration में remove किया गया। /clear route को अभी भी server-to-server द्वारा invoked किया जाता है StreamingServiceController द्वारा जब streaming services save किए जाते हैं।

MethodPathAuthPermissionDescription
POST/JWT(legacy) Save blocked IPs (batch)। कोई active client नहीं है
POST/clearJWTClear सभी blocked IPs specific services के लिए। Body: [{ serviceId, churchId }]

Delivery Logs

Base path: /messaging/deliverylogs

Sent messages (SMS, push notifications, email) के लिए delivery status को tracks करता है।

MethodPathAuthPermissionDescription
GET/content/:contentType/:contentIdJWTLoad delivery logs by content type और ID
GET/person/:personIdJWTLoad delivery logs एक person के लिए। Optional ?startDate=&endDate= filters
GET/recentJWTLoad recent delivery logs church के लिए। Optional ?limit= (default 100)
GET/:idJWTLoad एक delivery log by ID

संबंधित पृष्ठ