Skip to main content

BaseApp Chats

Project description

BaseApp Chats

This package provides a simple chat system for your project, where multiple profiles can chat with each other.

Requirements:

- **baseapp-core** >= 0.3.7
- **baseapp-profile** >= 0.2.4

Run pip install baseapp-chats And make sure to add the frozen version to your requirements/base.txt file

If you want to develop, install using this other guide.

How to use

Add baseapp_chats to your project's INSTALLED_APPS

Make sure your Profile's GraphQL Object Types extends ChatRoomsInterface interface:

from baseapp_chats.graphql.interfaces import ChatRoomsInterface

class ProfileObjectType(DjangoObjectType):
    class Meta:
        interfaces = (relay.Node, ChatRoomsInterface)

This is not necessary if you are using the baseapp-profile as it is without a custom ProfileObjectType implementation.

Expose ChatsMutations, ChatsQueries and ChatsSubscriptions in your GraphQL/graphene endpoint, like:

from baseapp_chats.graphql.mutations import ChatsMutations
from baseapp_chats.graphql.queries import ChatsQueries
from baseapp_chats.graphql.subscriptions import ChatsSubscriptions


class Query(graphene.ObjectType, ChatsQueries):
    pass


class Mutation(graphene.ObjectType, ChatsMutations):
    pass


class Subscription(graphene.ObjectType, ChatsSubscriptions):
    pass


schema = graphene.Schema(query=Query, mutation=Mutation, subscription=Subscription)

Those will expose the following queries, mutations and subscriptions:

Queries

  • chatRoom(id: ID!): Return a specific chatRoom

Mutations

  • chatRoomCreate(profileId: ID!, participants: [ID!]!): Create a chatRoom with your profile and multiple participants
  • chatRoomSendMessage(roomId: ID!, profileId: ID!, content: String!, inReplyToId: ID): Send a message in a room, using a specific profile. Optionally, you can reply to a message by passing the inReplyToId argument.
  • chatRoomReadMessages(roomId: ID!, profileId: ID!, messageIds: [ID]): Mark messages in a room as read by a specific profile, if messageIds is not passed, all messages will be marked as read.

Subscriptions

  • chatRoomOnRoomUpdate(profileId: ID!): Subscribe to chat rooms updates under your current profile
  • chatRoomOnMessagesCountUpdate(profileId: ID!): Subscribe to unread/read messages count updates under your current profile
  • chatRoomOnNewMessage(roomId: ID!): Subscribe to new messages in a specific room

How to develop

Clone the project inside your project's backend dir:

git clone git@github.com:silverlogic/baseapp-backend.git

And manually install the package:

pip install -e baseapp-backend/baseapp-chats

The -e flag will make it like any change you make in the cloned repo files will effect into the project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseapp-chats-0.0.1.tar.gz (19.1 kB view details)

Uploaded Source

File details

Details for the file baseapp-chats-0.0.1.tar.gz.

File metadata

  • Download URL: baseapp-chats-0.0.1.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for baseapp-chats-0.0.1.tar.gz
Algorithm Hash digest
SHA256 95dc5c6cec84920ba6290d3243879cd0a55c8a9213cb9ef4187b1905c46c0466
MD5 10cbb3370173a58d34d90cc998bc66be
BLAKE2b-256 718f3930e52ae01907ccf8aa9ab4fe61d318f0190061b3fc19611ac451b1af0a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page