User class

Represents a SDN User which may be a participant in a SDN Room.

Inheritance
Available extensions

Constructors

User(String id, {String? membership, String? displayName, String? avatarUrl, required Room room})
factory
User.fromState({Map<String, dynamic>? prevContent, required String stateKey, Map<String, dynamic> content = const {}, required String typeKey, required String eventId, required String senderId, required DateTime originServerTs, dynamic unsigned, required Room room})

Properties

asUser User
no setterinherited
attachmentMimetype String
Gets the mimetype of the attachment of a file event, or a blank string if not present
no setterinherited
attachmentMxcUrl Uri?
Gets the underlying mxc url of an attachment of a file event, or null if not present
no setterinherited
avatarUrl Uri?
The avatar if the user has one.
no setter
body String
Use this to get the body.
no setterinherited
canBan bool
Whether the client is able to ban/unban this user.
no setter
canChangePowerLevel bool
Whether the client is allowed to change the power level of this user. Please be aware that you can only set the power level to at least your own!
no setter
canKick bool
Whether the client is able to kick this user.
no setter
canRedact bool
Whether the client is allowed to redact this event.
no setterinherited
content Map<String, Object?>
getter/setter pairinherited
currentPresence Future<CachedPresence>
no setter
displayName String?
The displayname of the user if the user has set one.
no setter
eventId String
getter/setter pairinherited
fileSendingStatus FileSendingStatus?
If this event is in Status SENDING and it aims to send a file, then this shows the status of the file sending.
no setterinherited
formattedText String
Returns the formatted boy of this event if it has a formatted body.
no setterinherited
hasAttachment bool
Returns if a file event has an attachment
no setterinherited
hashCode int
The hash code for this object.
no setteroverride
hasThumbnail bool
Returns if a file event has a thumbnail
no setterinherited
id String
The full qualified SDN ID in the format @username:server.abc.
no setter
infoMap Map
Gets the info map of file events, or a blank map if none present
no setterinherited
isAttachmentEncrypted bool
Returns if a file events attachment is encrypted
no setterinherited
isEventTypeKnown bool
Returns if this is a known event type.
no setterinherited
isRichMessage bool
returns if a message is a rich message
no setterinherited
isThumbnailEncrypted bool
Returns if a file events thumbnail is encrypted
no setterinherited
membership Membership
The membership status of the user. One of: join invite leave ban
no setter
mention String
Get the mention text to use in a plain text body to mention this specific user in this specific room
no setter
mentionFragments Set<String>
Get the mention fragments for this user.
no setter
messageType String
no setterinherited
numberEmotes int
Gets the number of emotes in a given message. This is useful to determine if the emotes should be displayed bigger. If the body contains a reply then it is stripped. WARNING: This does not test if there are only emotes. Use event.onlyEmotes for that!
no setterinherited
onlyEmotes bool
Returns if a given event only has emotes, emojis or whitespace as content. If the body contains a reply then it is stripped. This is useful to determine if stand-alone emotes should be displayed bigger.
no setterinherited
originalSource SDNEvent?
no setterinherited
originServerTs DateTime
getter/setter pairinherited
plaintextBody String
Use this to get a plain-text representation of the event, stripping things like spoilers and thelike. Useful for plain text notifications.
no setterinherited
powerLevel int
Returns the power level of this user.
no setter
presence Presence?
The newest presence of this user if there is any and null if not.
no setter
prevContent Map<String, Object?>?
getter/setter pairinherited
receipts List<Receipt>
Returns a list of Receipt instances for this event.
no setterinherited
redacted bool
no setterinherited
redactedBecause Event?
Optional. The event that redacted this event, if any. Otherwise null.
no setterinherited
redacts String?
getter/setter pairinherited
relationshipEventId String?
Get the event ID that this relationship will reference. null if there is none
no setterinherited
relationshipType String?
Get the relationship type of an event. null if there is none
no setterinherited
room Room
The room this event belongs to. May be null.
finalinherited
roomId String?
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sender User
no setterinherited
senderFromMemoryOrFallback User
no setterinherited
senderId String
getter/setter pairinherited
stateKey String?
getter/setter pairinherited
stateKeyUser User?
no setterinherited
status EventStatus
The status of this event.
getter/setter pairinherited
text String
Returns the body of this event if it has a body.
no setterinherited
thumbnailInfoMap Map
Gets the thumbnail info map of file events, or a blank map if nonepresent
no setterinherited
thumbnailMimetype String
Gets the mimetype of the thumbnail of a file event, or a blank string if not present
no setterinherited
thumbnailMxcUrl Uri?
Gets the underlying mxc url of a thumbnail of a file event, or null if not present
no setterinherited
type String
getter/setter pairinherited
unsigned Map<String, Object?>?
getter/setter pairinherited

Methods

aggregatedEvents(Timeline timeline, String type) Set<Event>
Get all the aggregated event objects for a given type. To be able to do this you have to pass a timeline
inherited
attachmentOrThumbnailMxcUrl({bool getThumbnail = false}) Uri?
Gets the mxc url of an attachment/thumbnail of a file event, taking sizes into account, or null if not present
inherited
ban() Future<void>
Call the SDN API to ban this user from this room.
calcDisplayname({bool? formatLocalpart, bool? mxidLocalPartFallback, SDNLocalizations i18n = const SDNDefaultLocalizations()}) String
Returns the displayname or the local part of the SDN ID if the user has no displayname. If formatLocalpart is true, then the localpart will be formatted in the way, that all "_" characters are becomming white spaces and the first character of each word becomes uppercase. If mxidLocalPartFallback is true, then the local part of the mxid will be shown if there is no other displayname available. If not then this will return "Unknown user".
calcLocalizedBody(SDNLocalizations i18n, {bool withSenderNamePrefix = false, bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) Future<String>
Returns a localized String representation of this event. For a room list you may find withSenderNamePrefix useful. Set hideReply to crop all lines starting with '>'. With plaintextBody it'll use the plaintextBody instead of the normal body. removeMarkdown allow to remove the markdown formating from the event body. Usefull form message preview or notifications text.
inherited
calcLocalizedBodyFallback(SDNLocalizations i18n, {bool withSenderNamePrefix = false, bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) String
Works similar to calcLocalizedBody() but does not wait for the sender user to be fetched. If it is not in the cache it will just use the fallback and display the localpart of the MXID according to the values of formatLocalpart and mxidLocalPartFallback in the Client class.
inherited
calcUnlocalizedBody({bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) String
Calculating the body of an event regardless of localization.
inherited
downloadAndDecryptAttachment({bool getThumbnail = false, Future<Uint8List> downloadCallback(Uri)?}) Future<SDNFile>
Downloads (and decrypts if necessary) the attachment of this event and returns it as a SDNFile. If this event doesn't contain an attachment, this throws an error. Set getThumbnail to true to download the thumbnail instead.
inherited
fetchCurrentPresence() Future<CachedPresence>
The newest presence of this user if there is any. Fetches it from the server if necessary or returns offline.
fetchSenderUser() Future<User?>
Requests the user object of the sender of this event.
inherited
getAttachmentUrl({bool getThumbnail = false, bool useThumbnailMxcUrl = false, double width = 800.0, double height = 800.0, ThumbnailMethod method = ThumbnailMethod.scale, int minNoThumbSize = _minNoThumbSize, bool animated = false}) Uri?
Gets the attachment https URL to display in the timeline, taking into account if the original image is tiny. Returns null for encrypted rooms, if the image can't be fetched via http url or if the event does not contain an attachment. Set getThumbnail to true to fetch the thumbnail, set width, height and method for the respective thumbnailing properties. minNoThumbSize is the minimum size that an original image may be to not fetch its thumbnail, defaults to 80k useThumbnailMxcUrl says weather to use the mxc url of the thumbnail, rather than the original attachment. animated says weather the thumbnail is animated
inherited
getDisplayEvent(Timeline timeline) Event
Fetches the event to be rendered, taking into account all the edits and the like. It needs a timeline for that.
inherited
getLocalizedBody(SDNLocalizations i18n, {bool withSenderNamePrefix = false, bool hideReply = false, bool hideEdit = false, bool plaintextBody = false, bool removeMarkdown = false}) String
inherited
getReplyEvent(Timeline timeline) Future<Event?>
Searches for the reply event in the given timeline.
inherited
hasAggregatedEvents(Timeline timeline, String type) bool
Get whether this event has aggregated events from a certain type To be able to do that you need to pass a timeline
inherited
isAttachmentInLocalStore({bool getThumbnail = false}) Future<bool>
Returns if an attachment is in the local store
inherited
kick() Future<void>
Call the SDN API to kick this user from this room.
matchesEventOrTransactionId(String? search) bool
returns if this event matches the passed event or transaction id
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
redactEvent({String? reason, String? txid}) Future<String?>
Redacts this event. Throws ErrorResponse on error.
inherited
remove() Future<bool>
Removes this event if the status is sending, error or removed. This event will just be removed from the database and the timelines. Returns false if not removed.
inherited
requestKey() Future<void>
If this event is encrypted and the decryption was not successful because the session is unknown, this requests the session key from other devices in the room. If the event is not encrypted or the decryption failed because of a different error, this throws an exception.
inherited
sendAgain({String? txid}) Future<String?>
Try to send this event again. Only works with events of status -1.
inherited
setPower(int power) Future<void>
Call the SDN API to change the power level of this user.
setRedactionEvent(Event redactedBecause) → void
inherited
startDirectChat({bool? enableEncryption, List<StateEvent>? initialState, bool waitForSync = true}) Future<String>
Returns an existing direct chat ID with this user or creates a new one. Returns null on error.
toJson() Map<String, dynamic>
inherited
toString() String
A string representation of this object.
inherited
unban() Future<void>
Call the SDN API to unban this banned user from this room.

Operators

operator ==(dynamic other) bool
The equality operator.
override