User and note fetching fixes
ci/woodpecker/push/ociImagePush Pipeline was successful Details

This commit is contained in:
Natty 2023-12-27 04:40:13 +01:00
parent 69cb1c5220
commit 05469f68a8
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
3 changed files with 19 additions and 15 deletions

View File

@ -359,17 +359,17 @@ impl NoteResolver {
let mut select = note::Entity::find().add_aliased_columns(Some(USER), user::Entity); let mut select = note::Entity::find().add_aliased_columns(Some(USER), user::Entity);
if let Some(pins_user) = options.only_pins_from.clone() { if let Some(pins_user) = options.only_pins_from.clone() {
select = select.join_as( select = select
JoinType::InnerJoin, .join_as(
note::Relation::UserNotePining JoinType::InnerJoin,
.def() note::Relation::UserNotePining.def(),
.on_condition(move |left, _right| { ALIAS_PIN.clone(),
Expr::col((left, note::Column::UserId)) )
.eq(&pins_user) .filter(
.into_condition() Expr::col((ALIAS_PIN.clone(), user_note_pining::Column::UserId))
}), .eq(&pins_user)
ALIAS_PIN.clone(), .into_condition(),
) )
} }
if let Some(user_id) = &options.with_interactions_from { if let Some(user_id) = &options.with_interactions_from {

View File

@ -29,6 +29,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { host as localHost } from "@/config";
import { computed, defineAsyncComponent, watch } from "vue"; import { computed, defineAsyncComponent, watch } from "vue";
import * as os from "@/os"; import * as os from "@/os";
import { useRouter } from "@/router"; import { useRouter } from "@/router";
@ -60,9 +61,10 @@ let tab = $ref(props.page);
let user = $ref<null | packed.PackUserSelfMaybeAll>(null); let user = $ref<null | packed.PackUserSelfMaybeAll>(null);
let error = $ref<any>(null); let error = $ref<any>(null);
function fetchUser(refetch: boolean = true): void { function fetchUser(refetch: boolean = true, clear: boolean = true): void {
if (!props.acct) return; if (!props.acct) return;
user = null;
if (clear) user = null;
os.magApi( os.magApi(
endpoints.GetUserByAcct, endpoints.GetUserByAcct,
@ -78,11 +80,13 @@ function fetchUser(refetch: boolean = true): void {
new Date().getTime() - new Date().getTime() -
new Date(user.last_fetched_at).getTime() > new Date(user.last_fetched_at).getTime() >
dayMs) && dayMs) &&
user.host !== null &&
user.host !== localHost &&
refetch refetch
) { ) {
os.api("users/show", Acct.parse(props.acct)) os.api("users/show", Acct.parse(props.acct))
.then(() => { .then(() => {
fetchUser(false); fetchUser(false, false);
}) })
.catch((e) => { .catch((e) => {
error = e; error = e;

View File

@ -68,7 +68,7 @@ fn split_tag_inner(tag: impl AsRef<str>) -> (String, Option<String>) {
fn validate_tag_inner((name, host): (&str, Option<&str>)) -> Result<(), FediverseTagParseError> { fn validate_tag_inner((name, host): (&str, Option<&str>)) -> Result<(), FediverseTagParseError> {
if name if name
.chars() .chars()
.any(|c| !c.is_alphanumeric() && c != '-' && c != '.') .any(|c| !c.is_alphanumeric() && c != '-' && c != '_' && c != '.')
{ {
return Err(FediverseTagParseError::InvalidChar(name.to_owned())); return Err(FediverseTagParseError::InvalidChar(name.to_owned()));
} }