-
Notifications
You must be signed in to change notification settings - Fork 68
/
PresenceEvent.ts
69 lines (60 loc) · 1.64 KB
/
PresenceEvent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { MatrixEvent } from "./Event";
/**
* The allowed states of presence in Matrix.
*
* * `online`: The default state when the user is connected to an event stream.
* * `unavailable`: The user is not reachable at this time e.g. they are idle.
* * `offline`: The user is not connected to an event stream or is explicitly suppressing their profile information from being sent.
*
* @category Matrix event info
* @see PresenceEventContent
*/
export type PresenceState = "online" | "offline" | "unavailable";
/**
* Event content for m.presence events
* @category Matrix event contents
* @see PresenceEvent
*/
export interface PresenceEventContent {
/**
* The avatar URL for the user, if any.
*/
avatar_url?: string;
/**
* The display name for the user, if any.
*/
displayname?: string;
/**
* How long ago the user performed some action, in milliseconds.
*/
last_active_ago?: number;
/**
* The user's presence state.
*
* @see {@link PresenceState} for a description of each presence key.
*/
presence: PresenceState;
/**
* Whether or not the user is currently active.
*/
currently_active?: boolean;
/**
* A status message associated with this presence.
*/
status_msg?: string;
}
/**
* Wraps a m.presence ephemeral event in Matrix
* @category Matrix events
*/
export class PresenceEvent extends MatrixEvent<PresenceEventContent> {
constructor(event: any) {
super(event);
}
/**
* The current presence state for the user.
*/
public get presence(): PresenceState {
return this.content.presence;
}
}