Table of Contents

Class OutgoingMessageBuilder

Namespace
Signal.Domain.Messaging
Assembly
Signal.Domain.dll

Fluent builder for OutgoingMessage. Validation happens in Build().

public sealed class OutgoingMessageBuilder
Inheritance
OutgoingMessageBuilder
Inherited Members

Methods

AsViewOnce(bool)

Marks the message as view-once.

public OutgoingMessageBuilder AsViewOnce(bool viewOnce = true)

Parameters

viewOnce bool

Whether the message is view-once.

Returns

OutgoingMessageBuilder

This builder.

Build()

Validates the state and creates the immutable message.

public OutgoingMessage Build()

Returns

OutgoingMessage

The message.

Exceptions

SignalDomainException

There is no recipient; there is neither text, an attachment nor a sticker; a mention exceeds the text; a sticker is combined with attachments; or the link preview's URL is not in the text.

Editing(long)

Turns the send into an edit of a message sent earlier by the same account.

public OutgoingMessageBuilder Editing(long timestamp)

Parameters

timestamp long

Timestamp of the message to edit.

Returns

OutgoingMessageBuilder

This builder.

NotifySelf(bool)

Controls whether the sending account's other devices are notified.

public OutgoingMessageBuilder NotifySelf(bool notify = true)

Parameters

notify bool

Whether to notify the own devices.

Returns

OutgoingMessageBuilder

This builder.

Quoting(long, string, string?)

Replies to (quotes) a message.

public OutgoingMessageBuilder Quoting(long timestamp, string author, string? text = null)

Parameters

timestamp long

Timestamp of the quoted message.

author string

Phone number or UUID of the quoted message's author.

text string

Text of the quoted message, shown in the preview.

Returns

OutgoingMessageBuilder

This builder.

To(params IEnumerable<Recipient>)

Adds recipients. Duplicates are ignored. Phone numbers, account ids, usernames and group ids convert implicitly.

public OutgoingMessageBuilder To(params IEnumerable<Recipient> recipients)

Parameters

recipients IEnumerable<Recipient>

The recipients to add.

Returns

OutgoingMessageBuilder

This builder.

Exceptions

ArgumentException

A recipient is default (holds no value).

WithAttachment(ReadOnlySpan<byte>, string, string?)

Adds an attachment, encoding it as a data URI.

public OutgoingMessageBuilder WithAttachment(ReadOnlySpan<byte> content, string contentType, string? fileName = null)

Parameters

content ReadOnlySpan<byte>

The file content.

contentType string

The MIME type, e.g. image/png.

fileName string

Optional file name shown to recipients.

Returns

OutgoingMessageBuilder

This builder.

WithBase64Attachment(string)

Adds an attachment that is already base64 encoded (optionally as data URI).

public OutgoingMessageBuilder WithBase64Attachment(string base64OrDataUri)

Parameters

base64OrDataUri string

Plain base64, or data:<mime>;filename=<name>;base64,<data>.

Returns

OutgoingMessageBuilder

This builder.

WithLinkPreview(LinkPreview)

Attaches a link preview card. The URL must also appear in the message text, because Signal clients ignore previews of links that aren't in the text.

public OutgoingMessageBuilder WithLinkPreview(LinkPreview preview)

Parameters

preview LinkPreview

The preview.

Returns

OutgoingMessageBuilder

This builder.

Exceptions

SignalDomainException

The URL is not an absolute http or https URL.

WithLinkPreview(string, string?, string?, string?)

Attaches a link preview card for a URL contained in the message text.

public OutgoingMessageBuilder WithLinkPreview(string url, string? title = null, string? description = null, string? base64Thumbnail = null)

Parameters

url string

The previewed URL; must appear in the text.

title string

The card title.

description string

The card description.

base64Thumbnail string

The thumbnail image as base64 or data URI.

Returns

OutgoingMessageBuilder

This builder.

Exceptions

SignalDomainException

url is not an absolute http or https URL.

WithMention(string, int, int)

Mentions a user at a position in the text.

public OutgoingMessageBuilder WithMention(string author, int start, int length)

Parameters

author string

Phone number or UUID of the mentioned user.

start int

Start position in the text (UTF-16 code units).

length int

Length of the mentioned span.

Returns

OutgoingMessageBuilder

This builder.

Exceptions

SignalDomainException

start is negative or length is not positive.

WithSticker(Sticker)

Sends a sticker from a sticker pack installed on the account (see IStickerService).

public OutgoingMessageBuilder WithSticker(Sticker sticker)

Parameters

sticker Sticker

The sticker, e.g. Sticker.Parse("f3a9…:4").

Returns

OutgoingMessageBuilder

This builder.

WithSticker(string, int)

Sends a sticker from a sticker pack installed on the account.

public OutgoingMessageBuilder WithSticker(string packId, int stickerId)

Parameters

packId string

The hex id of the sticker pack.

stickerId int

The index of the sticker within the pack.

Returns

OutgoingMessageBuilder

This builder.

Exceptions

SignalDomainException

packId is not hex, or stickerId is negative.

WithStyledText(string)

Sets a text using Signal's markdown-like styling (Styled).

public OutgoingMessageBuilder WithStyledText(string text)

Parameters

text string

The styled text, e.g. bold and italic.

Returns

OutgoingMessageBuilder

This builder.

WithText(string?, TextMode)

Sets the message text.

public OutgoingMessageBuilder WithText(string? text, TextMode mode = TextMode.Normal)

Parameters

text string

The text.

mode TextMode

How the text is interpreted.

Returns

OutgoingMessageBuilder

This builder.