-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various small improvements to the "How To" guide (#432)
* Setup -> Set up * Use node: prefix when importing NodeJS modules * How-To: No need to install matrix-appservice * How-To: slack -> Slack * Add newsfile * README.md: Fix RegExp from +. to .+ * Update 432.doc * HOWTO.md: Avoid abbreviation "NB" and elaborate on Linux distro differences * README.md: Don't abbreviate AS API and CS API * Update HOWTO.md Co-authored-by: Will Hunt <[email protected]> Co-authored-by: Will Hunt <[email protected]>
- Loading branch information
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
How-To guide: Remove advise to install matrix-appservice and other small improvements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { StoredEvent } from "../../models/events/event"; | ||
|
||
export interface EventBridgeStore { | ||
/** | ||
* Insert an event, clobbering based on the ID of the StoredEvent. | ||
* @param event | ||
*/ | ||
upsertEvent(event: StoredEvent): Promise<void> | ||
/** | ||
* Get an existing event based on the provided matrix IDs. | ||
* @param roomId The ID of the room. | ||
* @param eventId The ID of the event. | ||
* @return A promise which resolves to the StoredEvent or null. | ||
*/ | ||
getEntryByMatrixId(roomId: string, eventId: string): Promise<StoredEvent|null> | ||
|
||
/** | ||
* Get an existing event based on the provided remote IDs. | ||
* @param roomId The ID of the room. | ||
* @param eventId The ID of the event. | ||
* @return A promise which resolves to the StoredEvent or null. | ||
*/ | ||
getEntryByRemoteId(roomId: string, eventId: string): Promise<StoredEvent|null> | ||
|
||
/** | ||
* Remove entries based on the event data. | ||
* @param event The event to remove. | ||
*/ | ||
removeEvent(event: StoredEvent): Promise<void> | ||
|
||
/** | ||
* Remove entries based on the matrix IDs. | ||
* @param roomId The ID of the room. | ||
* @param eventId The ID of the event. | ||
*/ | ||
removeEventByMatrixId(roomId: string, eventId: string): Promise<void> | ||
/** | ||
* Remove entries based on the matrix IDs. | ||
* @param roomId The ID of the room. | ||
* @param eventId The ID of the event. | ||
*/ | ||
removeEventByRemoteId(roomId: string, eventId: string): Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface RoomBridgeStore { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright 2021 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
/* | ||
* User activity storage format: | ||
* { | ||
* mxid: "matrix_id", | ||
* ts: [.. timestamps], | ||
* metadata: { | ||
* .. arbitrary activity-related metadata | ||
* } | ||
* } | ||
* Examples: | ||
* { | ||
* { | ||
* mxid: "@foo.bar.baz", | ||
* ts: [1234567890, 1234534234], | ||
* metadata: { | ||
* active: true, | ||
* } | ||
* } | ||
*/ | ||
import Datastore from "nedb"; | ||
import { BridgeStore } from "./bridge-store"; | ||
import { UserActivity, UserActivitySet } from "./user-activity"; | ||
|
||
export class UserActivityStore extends BridgeStore { | ||
/** | ||
* Construct a store suitable for user bridging information. | ||
* @param db The connected NEDB database instance | ||
*/ | ||
constructor (db: Datastore) { | ||
super(db); | ||
} | ||
|
||
public async storeUserActivity(mxid: string, activity: UserActivity): Promise<void> { | ||
this.upsert({ mxid }, { | ||
...activity, | ||
}); | ||
} | ||
|
||
public async getActivitySet(): Promise<UserActivitySet> { | ||
return this.select({}).then((records: any[]) => { | ||
const users: {[mxid: string]: any} = {}; | ||
for (const record of records) { | ||
users[record.mxid] = { | ||
ts: record.ts, | ||
metadata: record.metadata, | ||
}; | ||
} | ||
return { users } as UserActivitySet; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface UserBridgeStore { | ||
|
||
} |