Options
All
  • Public
  • Public/Protected
  • All
Menu

talk.js

Index

Type aliases

ConversationAccessLevel

ConversationAccessLevel: "ReadWrite" | "Read" | "None"

CustomFieldPredicate

CustomFieldPredicate: FieldPredicate<string> | "exists" | "!exists"

FieldPredicate

FieldPredicate: ["==" | "!=", T] | ["oneOf" | "!oneOf", T[]]

Functions

oneOnOneId

  • oneOnOneId(me: User | string, other: User | string): string
  • A helper method to predictably compute a Conversation ID based on participants' ids in the given conversation. Use this method if you want to simply create a conversation between two users, not related to a particular product, order or transaction.

    The order of the parameters does not matter. For example, Talk.oneOnOneId("a", "b") yields the same result as Talk.oneOnOneId("b", "a").

    This method takes the following steps:

    1. Take two ids of users and put them in an array
    2. Sort them lexicographically
    3. JSON encode them
    4. hash the result using SHA1, return the first 20 characters

    In pseudocode, this is what this function does:

    var sorted = [me.id, other.id].sort()
    var encoded = JSON.encode(sorted)
    var hash = sha1(encoded)
    return truncate(hash, 20)
    

    For a PHP implementation, see https://gist.github.com/eteeselink/4dc3ad32cc478986ff2b5b6361a1825f. Get in touch if you need our help implementing this in your backend language.

    Parameters

    • me: User | string
    • other: User | string

    Returns string

Generated using TypeDoc