pub async fn should_push<B: ChatBackend>(
backend: &B,
caller: &B::CallerCtx,
account_id: &Id,
cfg: &ChatPushConfig,
caps: &HashMap<Id, ChatPushCapability>,
msg: &Message,
owner: OwnerFlags,
) -> Result<bool, B::Error>Expand description
Whether a ChatMessagePush for the new inbound message msg goes to
a subscription whose chatPush entry for account_id is cfg.
caps maps each account that advertises
urn:ietf:params:jmap:chat:push to its capability object; a cfg for
an account not in caps counts as absent and gets false
(draft-atwood-jmap-chat-push-00 §PushSubscription Extension). owner
is the owner’s standing at delivery time, as for
build_chat_message_push.
Returns true only when the Chat matches cfg and none of the
§Delivery exclusions applies:
cfg.kindsandcfg.chatIdsboth match when present. §ChatPushConfig: “If bothkindsandchatIdsare present, a Chat matches only if its id appears inchatIdsand its kind appears inkinds.”- The sender is not the owner:
senderIdis notaccount_id. - The owner is still a member of the Chat. The account must hold the
Chat; for a group Chat its
membersmust have an entry whose id isaccount_id, and for a channel Chat its Space’smembersmust. - The Chat is not muted, unless the owner is targeted by one of the message’s broadcast
mentions. Direct mentions never bypass a mute, and neither does an
encrypted message (§End-to-End Encrypted Deployments: “never bypasses
mute suppression”). When
muteUntilis set, the Chat is muted until that time whatevermutedsays, because draft-atwood-jmap-chat-00 §ChatmuteUntilsays “Muting expires at this time” and clearingmutedafterwards is only a SHOULD. Otherwise the Chat is muted whenmutedistrue. AmuteUntilthat is not a seconds-precision UTCDate, or a system clock before 1970, counts as an active mute. - The sender’s
ChatContactis not blocked, perChatBackend::is_contact_blocked.
§Messages stored before the subscription
§Delivery: “The server MUST NOT deliver a ChatMessagePush in any of
the following cases: The message was stored before the
PushSubscription was created.” This function cannot see creation
order. The caller MUST read the set of subscriptions under the same lock
or transaction as the message write, and call this function only for
subscriptions in that set, including when delivery fans out
asynchronously afterwards.
§Errors
Returns the backend’s error if reading the Chat, its Space or the sender’s blocked status fails.