Table of Contents

Interface IUserMailPreferenceService

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

Which categories of mail a user receives, read and changed by that user or by staff holding Manage.

public interface IUserMailPreferenceService

Remarks

Checked in the service, not by scope attributes, because the rule is "your own, or any with users:manage", which a scope alone cannot say. Every member that names a user refuses a caller who is neither that user nor holds the system scope, with UnauthorizedAccessException.

Choices follow the user, not the team: one user has one set wherever they are a member. Only choices that differ from a category's default are stored, so changing a default changes it for everyone who never chose.

Methods

GetCategories()

Every registered category, built-in ones first and then in the order the host registered them.

IReadOnlyList<UserMailCategory> GetCategories()

Returns

IReadOnlyList<UserMailCategory>

GetCategoryFrequenciesAsync(CancellationToken)

How often each registered category was sent over the past year, per user who received it, in the order of GetCategories(); empty when the outbox cannot count.

Task<IReadOnlyList<UserMailCategoryFrequency>> GetCategoryFrequenciesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<UserMailCategoryFrequency>>

Remarks

Statistics across all users that name nobody, so any caller may read them. Computed in one query and kept for a few minutes.

GetChoicesAsync(string, CancellationToken)

The user's effective choice for every registered category, in the order of GetCategories().

Task<IReadOnlyList<UserMailChoice>> GetChoicesAsync(string userKey, CancellationToken cancellationToken = default)

Parameters

userKey string
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<UserMailChoice>>

Exceptions

UnauthorizedAccessException

The caller is not this user and does not hold users:manage.

GetTermsUrl()

Where the host's terms of use are, a site path or an absolute address, which a required category links to as the reason it is always sent; null when the host has none.

string GetTermsUrl()

Returns

string

ReceivesAsync(string, string, CancellationToken)

Whether the user receives mail in the category: always for a required one, otherwise their choice or the default.

Task<bool> ReceivesAsync(string userKey, string categoryKey, CancellationToken cancellationToken = default)

Parameters

userKey string
categoryKey string
cancellationToken CancellationToken

Returns

Task<bool>

Exceptions

ArgumentException

The category is not registered.

UnauthorizedAccessException

The caller is not this user and does not hold users:manage.

SetChoiceAsync(string, string, bool, CancellationToken)

Records whether the user receives an optional category, audited when the choice changes, and returns the choice now in force.

Task<UserMailChoice> SetChoiceAsync(string userKey, string categoryKey, bool receives, CancellationToken cancellationToken = default)

Parameters

userKey string
categoryKey string
receives bool
cancellationToken CancellationToken

Returns

Task<UserMailChoice>

Exceptions

ArgumentException

The category is not registered.

InvalidOperationException

The category is required and receives is false.

UnauthorizedAccessException

The caller is not this user and does not hold users:manage.