Fix: use correct username for friendica users; add some docs
This commit is contained in:
parent
274904c95a
commit
c2a6dc2e45
1 changed files with 7 additions and 5 deletions
|
@ -1,7 +1,6 @@
|
||||||
import Utils from "./Utils";
|
import Utils from "./Utils";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import MastodonPoster from "./Mastodon";
|
import MastodonPoster from "./Mastodon";
|
||||||
import {userInfo} from "os";
|
|
||||||
|
|
||||||
export interface UserInfo {
|
export interface UserInfo {
|
||||||
"id": number,
|
"id": number,
|
||||||
|
@ -23,7 +22,7 @@ export default class OsmUserInfo {
|
||||||
private _userData: UserInfo = undefined
|
private _userData: UserInfo = undefined
|
||||||
private readonly _cachingPath: string | undefined;
|
private readonly _cachingPath: string | undefined;
|
||||||
|
|
||||||
constructor(userId: number, options:
|
constructor(userId: number, options?:
|
||||||
{
|
{
|
||||||
osmBackend?: string,
|
osmBackend?: string,
|
||||||
cacheDir?: string
|
cacheDir?: string
|
||||||
|
@ -54,8 +53,8 @@ export default class OsmUserInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Mastodon username of the this OSM-user to ping them.
|
* Gets the Mastodon username of the given OSM-user to ping them.
|
||||||
* @param mastodonApi: will be used to lookup the metadata of the user; if they have '#nobot' in their bio, don't mention them
|
* @param mastodonApi will be used to lookup the metadata of the user; if they have '#nobot' in their bio, don't mention them
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
public async GetMastodonUsername(mastodonApi: MastodonPoster): Promise<string | undefined> {
|
public async GetMastodonUsername(mastodonApi: MastodonPoster): Promise<string | undefined> {
|
||||||
|
@ -70,7 +69,7 @@ export default class OsmUserInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(mastodonLinks[0])
|
const url = new URL(mastodonLinks[0])
|
||||||
const username = url.pathname.substring(1) + (url.host === mastodonApi.hostname ? "" : "@" + url.host)
|
const username = url.pathname.split("/").at(-1) + (url.host === mastodonApi.hostname ? "" : "@" + url.host)
|
||||||
|
|
||||||
if (await mastodonApi.hasNoBot(username)) {
|
if (await mastodonApi.hasNoBot(username)) {
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -85,6 +84,9 @@ export default class OsmUserInfo {
|
||||||
return useraccount
|
return useraccount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the 'href' of every link with `rel=me`
|
||||||
|
*/
|
||||||
public async getMeLinks(): Promise<string[]> {
|
public async getMeLinks(): Promise<string[]> {
|
||||||
const userdata = await this.getUserInfo()
|
const userdata = await this.getUserInfo()
|
||||||
const div = document.createElement("div")
|
const div = document.createElement("div")
|
||||||
|
|
Loading…
Reference in a new issue