Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(fetcher): allow updating of post tags
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Nov 20, 2022
1 parent b63afcf commit 39b8127
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion common_front-end/fetchers/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import type {
PostIdentifierListDocument
} from "$/types/documents/post"

import { POST_LINK, COUNT_COMMENTS } from "$/constants/template_links"
import {
POST_LINK,
COUNT_COMMENTS,
UPDATE_TAG_OF_POST_LINK
} from "$/constants/template_links"

import BaseFetcher from "$@/fetchers/base"
import specializePath from "$/helpers/specialize_path"
Expand Down Expand Up @@ -67,4 +71,31 @@ export default class PostFetcher extends BaseFetcher<
PostIdentifierListDocument
>>
}

async updateAttachedTags(id: string, attachedRoleIDs: string[]): Promise<Response<
PostResourceIdentifier,
PostAttributes<"serialized">,
PostAttributes<"deserialized">,
PostResource,
DeserializedPostResource,
null
>> {
return await this.handleResponse(
this.patchJSON(UPDATE_TAG_OF_POST_LINK, {
id
}, {
"data": attachedRoleIDs.map(roleID => ({
"id": roleID,
"type": "role"
}))
})
) as Response<
PostResourceIdentifier,
PostAttributes<"serialized">,
PostAttributes<"deserialized">,
PostResource,
DeserializedPostResource,
null
>
}
}

0 comments on commit 39b8127

Please sign in to comment.