Skip to content

Commit 95a94cd

Browse files
authored
Remove hacky custom status feature (#2350)
This is unstable, so should be more than safe to just outright remove without notice.
1 parent 6b5f4aa commit 95a94cd

File tree

3 files changed

+0
-51
lines changed

3 files changed

+0
-51
lines changed

src/client.ts

-20
Original file line numberDiff line numberDiff line change
@@ -5063,26 +5063,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
50635063
return getHttpUriForMxc(this.baseUrl, mxcUrl, width, height, resizeMethod, allowDirectLinks);
50645064
}
50655065

5066-
/**
5067-
* Sets a new status message for the user. The message may be null/falsey
5068-
* to clear the message.
5069-
* @param {string} newMessage The new message to set.
5070-
* @return {Promise} Resolves: to nothing
5071-
* @return {module:http-api.MatrixError} Rejects: with an error response.
5072-
*/
5073-
public _unstable_setStatusMessage(newMessage: string): Promise<void> { // eslint-disable-line
5074-
const type = "im.vector.user_status";
5075-
return Promise.all(this.getRooms().map(async (room) => {
5076-
const isJoined = room.getMyMembership() === "join";
5077-
const looksLikeDm = room.getInvitedAndJoinedMemberCount() === 2;
5078-
if (!isJoined || !looksLikeDm) return;
5079-
// Check power level separately as it's a bit more expensive.
5080-
const maySend = room.currentState.mayClientSendStateEvent(type, this);
5081-
if (!maySend) return;
5082-
await this.sendStateEvent(room.roomId, type, { status: newMessage }, this.getUserId());
5083-
})).then(); // .then to fix return type
5084-
}
5085-
50865066
/**
50875067
* @param {Object} opts Options to apply
50885068
* @param {string} opts.presence One of "online", "offline" or "unavailable"

src/models/user.ts

-21
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export enum UserEvent {
2727
Presence = "User.presence",
2828
CurrentlyActive = "User.currentlyActive",
2929
LastPresenceTs = "User.lastPresenceTs",
30-
/* @deprecated */
31-
_UnstableStatusMessage = "User.unstable_statusMessage",
3230
}
3331

3432
export type UserEventHandlerMap = {
@@ -37,7 +35,6 @@ export type UserEventHandlerMap = {
3735
[UserEvent.Presence]: (event: MatrixEvent | undefined, user: User) => void;
3836
[UserEvent.CurrentlyActive]: (event: MatrixEvent | undefined, user: User) => void;
3937
[UserEvent.LastPresenceTs]: (event: MatrixEvent | undefined, user: User) => void;
40-
[UserEvent._UnstableStatusMessage]: (user: User) => void;
4138
};
4239

4340
export class User extends TypedEventEmitter<UserEvent, UserEventHandlerMap> {
@@ -59,8 +56,6 @@ export class User extends TypedEventEmitter<UserEvent, UserEventHandlerMap> {
5956
presence: null,
6057
profile: null,
6158
};
62-
// eslint-disable-next-line camelcase
63-
public unstable_statusMessage = "";
6459

6560
/**
6661
* Construct a new User. A User must have an ID and can optionally have extra
@@ -81,9 +76,6 @@ export class User extends TypedEventEmitter<UserEvent, UserEventHandlerMap> {
8176
* when a user was last active.
8277
* @prop {Boolean} currentlyActive Whether we should consider lastActiveAgo to be
8378
* an approximation and that the user should be seen as active 'now'
84-
* @prop {string} unstable_statusMessage The status message for the user, if known. This is
85-
* different from the presenceStatusMsg in that this is not tied to
86-
* the user's presence, and should be represented differently.
8779
* @prop {Object} events The events describing this user.
8880
* @prop {MatrixEvent} events.presence The m.presence event for this user.
8981
*/
@@ -219,19 +211,6 @@ export class User extends TypedEventEmitter<UserEvent, UserEventHandlerMap> {
219211
public getLastActiveTs(): number {
220212
return this.lastPresenceTs - this.lastActiveAgo;
221213
}
222-
223-
/**
224-
* Manually set the user's status message.
225-
* @param {MatrixEvent} event The <code>im.vector.user_status</code> event.
226-
* @fires module:client~MatrixClient#event:"User.unstable_statusMessage"
227-
*/
228-
// eslint-disable-next-line
229-
public unstable_updateStatusMessage(event: MatrixEvent): void {
230-
if (!event.getContent()) this.unstable_statusMessage = "";
231-
else this.unstable_statusMessage = event.getContent()["status"];
232-
this.updateModifiedTime();
233-
this.emit(UserEvent._UnstableStatusMessage, this);
234-
}
235214
}
236215

237216
/**

src/sync.ts

-10
Original file line numberDiff line numberDiff line change
@@ -1295,16 +1295,6 @@ export class SyncApi {
12951295
if (e.isState() && e.getType() == "m.room.encryption" && this.opts.crypto) {
12961296
await this.opts.crypto.onCryptoEvent(e);
12971297
}
1298-
if (e.isState() && e.getType() === "im.vector.user_status") {
1299-
let user = client.store.getUser(e.getStateKey());
1300-
if (user) {
1301-
user.unstable_updateStatusMessage(e);
1302-
} else {
1303-
user = createNewUser(client, e.getStateKey());
1304-
user.unstable_updateStatusMessage(e);
1305-
client.store.storeUser(user);
1306-
}
1307-
}
13081298
};
13091299

13101300
await utils.promiseMapSeries(stateEvents, processRoomEvent);

0 commit comments

Comments
 (0)