def get(self, uid=None): """ 获取通知,传入 uid: str 来指定获取用于指定用户的通知,缺省 uid=None 获取所有通知 """ notices = [] for r in self.collection.find() or []: n = Notice().from_dict(r) if n.is_expired(): self.drop_expired(n) if uid == None or n.is_for_user(uid): notices.append(n.dumps()) return notices