Coder Social home page Coder Social logo

Comments (3)

tiltec avatar tiltec commented on June 12, 2024 1

But in any case, the backend fix could come first. And then we'll see the failures pop up in frontend sentry.

from karrot-frontend.

tiltec avatar tiltec commented on June 12, 2024

I ran a quick test in the backend. When frontend sends seen_up_to, the backend seems to create a participant and save it, even when there was no participant before. I guess this shouldn't happen and we can prevent it in backend. Maybe by returning an error. Then we go to frontend and make sure that it doesn't trigger the error...

So in that sense, backend is allowed to create a participant when the notifications field is set properly, but otherwise not.

    def test_mark_seen_up_to_when_not_in_conversation(self):
        user = UserFactory()
        group = GroupFactory(members=[self.user2, user])
        conversation = ConversationFactory(group=group, participants=[self.user2])
        message = conversation.messages.create(author=self.user2, content='yay')
        self.client.force_login(user=user)

        response = self.client.get('/api/conversations/{}/'.format(conversation.id), format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['seen_up_to'], None)
        self.assertFalse(ConversationParticipant.objects.filter(conversation=conversation.id, user=user.id).exists())

        data = {'seen_up_to': message.id}
        response = self.client.patch('/api/conversations/{}/'.format(conversation.id), data, format='json')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['seen_up_to'], message.id)

        participant = ConversationParticipant.objects.get(conversation=conversation.id, user=user.id)
        self.assertFalse(ConversationParticipant.objects.filter(conversation=conversation.id, user=user.id).exists())
        print(participant)
        self.assertEqual(participant.seen_up_to, message)

from karrot-frontend.

nicksellen avatar nicksellen commented on June 12, 2024

Great, sounds promising.... I wonder if it's possible to recreate the frontend sending spurious seen_up_to API requests? That would make it feel quite likely to be the cause. I couldn't find an obvious way from a glance...

We do check whether the user is a participant here before marking as read:

markRead (messageId) {
if (!this.isParticipant) return // no marking as read if not part of it ...
const isThreadReply = this.conversation.thread && this.messageId !== this.conversation.thread
// TODO: check conversation.unreadMessageCount is available
if (!isThreadReply && this.conversation.unreadMessageCount > 0) {
this.markSeenUpTo({
conversationId: this.conversation.id,
messageId,
})
}
// TODO: check threadMeta.unreadReplyCount available?
if (isThreadReply && this.conversation.threadMeta && this.conversation.threadMeta.unreadReplyCount > 0) {
this.markThreadSeenUpTo({
threadId: this.conversation.thread,
messageId,
})
}
},

from karrot-frontend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.